From ab69abf2daf7b3b8791e3f58afcec25f8e3d4d60 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 3 Dec 2023 16:18:21 +0100 Subject: [PATCH] Fixed bug with URL rewriting and trailing slash redirection --- svr.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svr.js b/svr.js index abab8af..726cb1f 100644 --- a/svr.js +++ b/svr.js @@ -4316,11 +4316,11 @@ if (!cluster.isPrimary) { // Trailing slash redirection function redirectTrailingSlashes(callback) { - if (!disableTrailingSlashRedirects && href[href.length - 1] != "/") { + if (!disableTrailingSlashRedirects && href[href.length - 1] != "/" && origHref[origHref.length - 1] != "/") { fs.stat("." + decodeURIComponent(href), function (err, stats) { if (err || !stats.isDirectory()) { try { - callback(); + callback(); } catch (err) { callServerError(500, undefined, err); } @@ -4328,7 +4328,7 @@ if (!cluster.isPrimary) { var destinationURL = uobject; destinationURL.path = null; destinationURL.href = null; - destinationURL.pathname += "/"; + destinationURL.pathname = origHref + "/"; destinationURL.hostname = null; destinationURL.host = null; destinationURL.port = null;