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 // Trailing slash redirection
function redirectTrailingSlashes(callback) { 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) { fs.stat("." + decodeURIComponent(href), function (err, stats) {
if (err || !stats.isDirectory()) { if (err || !stats.isDirectory()) {
try { try {
@ -4328,7 +4328,7 @@ if (!cluster.isPrimary) {
var destinationURL = uobject; var destinationURL = uobject;
destinationURL.path = null; destinationURL.path = null;
destinationURL.href = null; destinationURL.href = null;
destinationURL.pathname += "/"; destinationURL.pathname = origHref + "/";
destinationURL.hostname = null; destinationURL.hostname = null;
destinationURL.host = null; destinationURL.host = null;
destinationURL.port = null; destinationURL.port = null;