From d633707ea588d379a08579881c3a9b9ab0dd3604 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sat, 2 Mar 2024 22:11:50 +0100 Subject: [PATCH] Prevent redirect loops with fallback replacement --- svr.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/svr.js b/svr.js index ff2a8a2..5e258f3 100644 --- a/svr.js +++ b/svr.js @@ -4587,6 +4587,10 @@ if (!cluster.isPrimary) { var location = ""; if (regexI[nonscodeIndex]) { location = req.url.replace(regexI[nonscodeIndex], nonscode.location); + if(location == req.url) { + // Fallback replacement + location = hrefWithoutDuplicateSlashes.replace(regexI[nonscodeIndex], nonscode.location); + } } else if (req.url.split("?")[1] == undefined || req.url.split("?")[1] == null || req.url.split("?")[1] == "" || req.url.split("?")[1] == " ") { location = nonscode.location; } else {