File: drop-url-join-dependency.patch

package info (click to toggle)
node-http-server 14.1.1%2B~cs3.16.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: javascript: 5,850; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 976 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Description: Drop url-join dependency
Author: sandra uwah <sandrauwah282@gmail.com>
Forwarded: not-needed
--- a/lib/core/index.js
+++ b/lib/core/index.js
@@ -6,7 +6,6 @@
 const { Readable } = require('stream');
 const buffer = require('buffer');
 const mime = require('mime');
-const urlJoin = require('url-join');
 const showDir = require('./show-dir');
 const version = require('../../package.json').version;
 const status = require('./status-handlers');
@@ -389,11 +388,9 @@
             }
 
             if (autoIndex) {
+              const uri = encodeURIComponent(pathname);
               middleware({
-                url: urlJoin(
-                  encodeURIComponent(pathname),
-                  `/index.${defaultExt}`
-                ),
+                url: /%2F$/.test(uri) ? `${uri}index.${defaultExt}` : `${uri}/index.${defaultExt}`,
                 headers: req.headers,
               }, res, (autoIndexError) => {
                 if (autoIndexError) {