1
0
Fork 0
forked from svrjs/svrjs

Fix URL rewriter always remove double slashes

This commit is contained in:
Dorian Niemiec 2024-03-02 22:45:27 +01:00
parent cbbe4c9bc5
commit 47803c217b

6
svr.js
View file

@ -4317,11 +4317,13 @@ if (!cluster.isPrimary) {
doCallback = false; doCallback = false;
break; break;
} }
var tempRewrittenURL = rewrittenURL;
if (!mapEntry.allowDoubleSlashes) { if (!mapEntry.allowDoubleSlashes) {
address = address.replace(/\/+/g,"/"); address = address.replace(/\/+/g,"/");
rewrittenURL = address; tempRewrittenURL = address;
} }
if (matchHostname(mapEntry.host) && ipMatch(mapEntry.ip, req.socket ? req.socket.localAddress : undefined) && address.match(createRegex(mapEntry.definingRegex)) && !(mapEntry.isNotDirectory && _fileState == 2) && !(mapEntry.isNotFile && _fileState == 1)) { if (matchHostname(mapEntry.host) && ipMatch(mapEntry.ip, req.socket ? req.socket.localAddress : undefined) && address.match(createRegex(mapEntry.definingRegex)) && !(mapEntry.isNotDirectory && _fileState == 2) && !(mapEntry.isNotFile && _fileState == 1)) {
rewrittenURL = tempRewrittenURL;
try { try {
mapEntry.replacements.forEach(function (replacement) { mapEntry.replacements.forEach(function (replacement) {
rewrittenURL = rewrittenURL.replace(createRegex(replacement.regex), replacement.replacement); rewrittenURL = rewrittenURL.replace(createRegex(replacement.regex), replacement.replacement);
@ -4329,7 +4331,7 @@ if (!cluster.isPrimary) {
if (mapEntry.append) rewrittenURL += mapEntry.append; if (mapEntry.append) rewrittenURL += mapEntry.append;
} catch (err) { } catch (err) {
doCallback = false; doCallback = false;
callback(err, address); callback(err, null);
} }
break; break;
} }