From 47803c217bc66b1fac41c694cfebba8d6d3d3617 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 2 Mar 2024 22:45:27 +0100 Subject: [PATCH] Fix URL rewriter always remove double slashes --- svr.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/svr.js b/svr.js index 5261918..d6c81c3 100644 --- a/svr.js +++ b/svr.js @@ -4317,11 +4317,13 @@ if (!cluster.isPrimary) { doCallback = false; break; } + var tempRewrittenURL = rewrittenURL; if (!mapEntry.allowDoubleSlashes) { 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)) { + rewrittenURL = tempRewrittenURL; try { mapEntry.replacements.forEach(function (replacement) { rewrittenURL = rewrittenURL.replace(createRegex(replacement.regex), replacement.replacement); @@ -4329,7 +4331,7 @@ if (!cluster.isPrimary) { if (mapEntry.append) rewrittenURL += mapEntry.append; } catch (err) { doCallback = false; - callback(err, address); + callback(err, null); } break; }