From d75779cb55d478de2c0e56c10077f6029a1aec7b Mon Sep 17 00:00:00 2001 From: Xmader Date: Sun, 22 Dec 2019 15:00:14 -0500 Subject: [PATCH 1/2] use extatic --- lib/http-server.js | 4 ++-- package-lock.json | 22 +++++++++++----------- package.json | 6 +++++- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/http-server.js b/lib/http-server.js index 626a5a845..0f56582f1 100644 --- a/lib/http-server.js +++ b/lib/http-server.js @@ -2,7 +2,7 @@ var fs = require('fs'), union = require('union'), - ecstatic = require('ecstatic'), + extatic = require('extatic'), auth = require('basic-auth'), httpProxy = require('http-proxy'), corser = require('corser'), @@ -148,7 +148,7 @@ function HttpServer(options) { }); } - before.push(ecstatic({ + before.push(extatic({ root: this.root, cache: this.cache, showDir: this.showDir, diff --git a/package-lock.json b/package-lock.json index 6b84be830..a7c897c5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -869,17 +869,6 @@ "safer-buffer": "^2.1.0" } }, - "ecstatic": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/ecstatic/-/ecstatic-3.3.2.tgz", - "integrity": "sha512-fLf9l1hnwrHI2xn9mEDT7KIi22UDqA2jaCwyCbSUJh9a1V+LEUSL/JO/6TIz/QyuBURWUHrFL5Kg2TtO1bkkog==", - "requires": { - "he": "^1.1.1", - "mime": "^1.6.0", - "minimist": "^1.1.0", - "url-join": "^2.0.5" - } - }, "enabled": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", @@ -1038,6 +1027,17 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "extatic": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/extatic/-/extatic-3.3.4.tgz", + "integrity": "sha512-ODESx81AzTHXR2tNlG4j7fos4OmHJD5ln3CXLRD57AHch5h1HH0wnl6ccPfpwp0UmjcBGx0ePX69Gwj42xOFTw==", + "requires": { + "he": "^1.1.1", + "mime": "^1.6.0", + "minimist": "^1.1.0", + "url-join": "^2.0.5" + } + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", diff --git a/package.json b/package.json index c12cceede..e6901324d 100644 --- a/package.json +++ b/package.json @@ -76,13 +76,17 @@ { "name": "Jade Michael Thornton", "email": "jade@jmthornton.net" + }, + { + "name": "Xmader", + "email": "xmader@outlook.com" } ], "dependencies": { "basic-auth": "^1.0.3", "colors": "^1.3.3", "corser": "^2.0.1", - "ecstatic": "^3.3.2", + "extatic": "^3.3.4", "http-proxy": "^1.17.0", "opener": "^1.5.1", "optimist": "~0.6.1", From b291d4690edcc4e3cd866d0e6a061b84c75f5ad7 Mon Sep 17 00:00:00 2001 From: Xmader Date: Sun, 22 Dec 2019 15:02:03 -0500 Subject: [PATCH 2/2] remove the hacky patch that fixes 525 (since it has been fixed in extatic) --- lib/http-server.js | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/lib/http-server.js b/lib/http-server.js index 0f56582f1..a9600d036 100644 --- a/lib/http-server.js +++ b/lib/http-server.js @@ -6,33 +6,8 @@ var fs = require('fs'), auth = require('basic-auth'), httpProxy = require('http-proxy'), corser = require('corser'), - path = require('path'), secureCompare = require('secure-compare'); -// a hacky and direct workaround to fix https://github.com/http-party/http-server/issues/525 -function getCaller() { - try { - var stack = new Error().stack; - var stackLines = stack.split('\n'); - var callerStack = stackLines[3]; - return callerStack.match(/at (.+) \(/)[1]; - } - catch (error) { - return ''; - } -} - -var _pathNormalize = path.normalize; -path.normalize = function (p) { - var caller = getCaller(); - var result = _pathNormalize(p); - // https://github.com/jfhbrook/node-ecstatic/blob/master/lib/ecstatic.js#L20 - if (caller === 'decodePathname') { - result = result.replace(/\\/g, '/'); - } - return result; -}; - // // Remark: backwards compatibility for previous // case convention of HTTP