Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions lib/http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,12 @@

var fs = require('fs'),
union = require('union'),
ecstatic = require('ecstatic'),
extatic = require('extatic'),
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
Expand Down Expand Up @@ -148,7 +123,7 @@ function HttpServer(options) {
});
}

before.push(ecstatic({
before.push(extatic({
root: this.root,
cache: this.cache,
showDir: this.showDir,
Expand Down
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,17 @@
{
"name": "Jade Michael Thornton",
"email": "[email protected]"
},
{
"name": "Xmader",
"email": "[email protected]"
}
],
"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",
Expand Down