This commit is contained in:
Rishi Raj Jain 2023-09-28 00:22:52 +05:30
parent 0b232095bf
commit d59f3bd6d7

View file

@ -38,7 +38,7 @@ export function createServer(
return res; return res;
} }
let pathForSend = encodedURI; let pathToSend = encodedURI;
if (trailingSlash === 'never') { if (trailingSlash === 'never') {
if (pathname.endsWith('/')) { if (pathname.endsWith('/')) {
@ -49,10 +49,10 @@ export function createServer(
return res; return res;
} }
} }
pathForSend = encodedURI + '/'; pathToSend = encodedURI + '/';
} }
const stream = send(req, pathForSend, { const stream = send(req, pathToSend, {
root: fileURLToPath(client), root: fileURLToPath(client),
dotfiles: pathname.startsWith('/.well-known/') ? 'allow' : 'deny', dotfiles: pathname.startsWith('/.well-known/') ? 'allow' : 'deny',
}); });
@ -79,7 +79,7 @@ export function createServer(
location = req.url + '/'; location = req.url + '/';
} }
if (!pathForSend.endsWith('/')) { if (!pathToSend.endsWith('/')) {
res.statusCode = 301; res.statusCode = 301;
res.setHeader('Location', location); res.setHeader('Location', location);
res.end(location); res.end(location);