forked from svrjs/svrjs
Lint out the codebase.
This commit is contained in:
parent
2075d41ab3
commit
e94391f197
4 changed files with 34 additions and 29 deletions
|
@ -6,9 +6,8 @@ module.exports = (req, res, logFacilities, config, next) => {
|
|||
!req.isProxy &&
|
||||
!config.disableTrailingSlashRedirects &&
|
||||
req.parsedURL.pathname[req.parsedURL.pathname.length - 1] != "/" &&
|
||||
req.originalParsedURL.pathname[
|
||||
req.originalParsedURL.pathname.length - 1
|
||||
] != "/"
|
||||
req.originalParsedURL.pathname[req.originalParsedURL.pathname.length - 1] !=
|
||||
"/"
|
||||
) {
|
||||
fs.stat(
|
||||
"." + decodeURIComponent(req.parsedURL.pathname),
|
||||
|
@ -20,12 +19,16 @@ module.exports = (req, res, logFacilities, config, next) => {
|
|||
res.error(500, err);
|
||||
}
|
||||
} else {
|
||||
res.redirect(req.originalParsedURL.pathname + "/" + req.parsedURL.search + req.parsedURL.hash);
|
||||
res.redirect(
|
||||
req.originalParsedURL.pathname +
|
||||
"/" +
|
||||
req.parsedURL.search +
|
||||
req.parsedURL.hash,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -125,7 +125,8 @@ module.exports = (req, res, logFacilities, config, next) => {
|
|||
logFacilities.errmessage("Content blocked.");
|
||||
return;
|
||||
} else if (sHref != req.parsedURL.pathname) {
|
||||
var rewrittenAgainURL = sHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
var rewrittenAgainURL =
|
||||
sHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
logFacilities.resmessage(
|
||||
"URL sanitized: " + req.url + " => " + rewrittenAgainURL,
|
||||
);
|
||||
|
|
|
@ -11,7 +11,8 @@ module.exports = (req, res, logFacilities, config, next) => {
|
|||
|
||||
// Check if URL is "dirty"
|
||||
if (req.parsedURL.pathname != sanitizedHref && !req.isProxy) {
|
||||
let sanitizedURL = sanitizedHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
let sanitizedURL =
|
||||
sanitizedHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
logFacilities.resmessage(
|
||||
"URL sanitized: " + req.url + " => " + sanitizedURL,
|
||||
);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const url = require("url");
|
||||
const createRegex = require("../utils/createRegex.js");
|
||||
const ipMatch = require("../utils/ipMatch.js");
|
||||
const sanitizeURL = require("../utils/urlSanitizer.js");
|
||||
|
@ -113,7 +112,8 @@ module.exports = (req, res, logFacilities, config, next) => {
|
|||
logFacilities.errmessage("Content blocked.");
|
||||
return;
|
||||
} else if (sHref != req.parsedURL.pathname) {
|
||||
let rewrittenAgainURL = sHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
let rewrittenAgainURL =
|
||||
sHref + req.parsedURL.search + req.parsedURL.hash;
|
||||
logFacilities.resmessage(
|
||||
"URL sanitized: " + req.url + " => " + rewrittenAgainURL,
|
||||
);
|
||||
|
|
Reference in a new issue