Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else {
// Restore the request to its original form.
request.originalUrl = request.url = originalUrl;
parseUrl(request);
}
}
}
/**
* Because serveIndex() does not know about Defiant's directory structure,
* it assumes that all the files' paths are relative to the domain. We must
* therefore intercept the function that prints the file listing and inject the
* proper subdirectory path.
*/
const originalServeIndexHtml = serveIndex.html;
serveIndex.html = function() {
if (arguments[0].__defiant_discarded) {
if (arguments[4] == '/') {
arguments[2].unshift('..');
}
arguments[4] = arguments[0].__defiant_discarded + arguments[4];
}
originalServeIndexHtml.apply(this, arguments);
};
module.exports = ServeDirectory;
}
else {
// Restore the request to its original form.
request.originalUrl = request.url = originalUrl;
parseUrl(request);
}
}
}
/**
* Because serveIndex() does not know about Defiant's directory structure,
* it assumes that all the files' paths are relative to the domain. We must
* therefore intercept the function that prints the file listing and inject the
* proper subdirectory path.
*/
const originalServeIndexHtml = serveIndex.html;
serveIndex.html = function() {
if (arguments[0].__defiant_discarded) {
if (arguments[4] == '/') {
arguments[2].unshift('..');
}
arguments[4] = arguments[0].__defiant_discarded + arguments[4];
}
originalServeIndexHtml.apply(this, arguments);
};
module.exports = ServeDirectory;