From c78859d6992ca0d08d73f29cd9cf32225f2a501d Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Thu, 21 Nov 2024 00:14:30 +0100 Subject: [PATCH] Fix double "?" in the REQUEST_URL environment variable when URL rewriting is used --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5d4b441..0a24893 100644 --- a/index.js +++ b/index.js @@ -251,7 +251,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e nEnv["PATH_TRANSLATED"] = b ? ((process.cwd() + decodeURIComponent(require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : ""; nEnv["REQUEST_METHOD"] = req.method; nEnv["SCGI"] = "1"; - nEnv["REQUEST_URI"] = (!origHref || origHref == href) ? req.url : (origHref + (uobject.search ? ("?" + uobject.search) : "")); + nEnv["REQUEST_URI"] = (!origHref || origHref == href) ? req.url : (origHref + (uobject.search ? ((uobject.search[0] == "?" ? "" : "?") + uobject.search) : "")); nEnv["REMOTE_ADDR"] = (req.socket.realRemoteAddress ? req.socket.realRemoteAddress : ((req.headers["x-forwarded-for"] && configJSON.enableIPSpoofing) ? req.headers["x-forwarded-for"].split(",")[0].replace(/ /g, "") : req.socket.remoteAddress)).replace(/^::ffff:/i, ""); if(req.socket.realRemoteAddress && req.socket.realRemotePort) { nEnv["REMOTE_PORT"] = req.socket.realRemotePort;