1
0
Fork 0
forked from svrjs/svrjs

Fixed bug with URL rewriting and trailing slash redirection

This commit is contained in:
Dorian Niemiec 2023-12-03 16:18:21 +01:00
parent 33d89f01d3
commit ab69abf2da

4
svr.js
View file

@ -4316,7 +4316,7 @@ 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 {
@ -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;