From 4bbaf732b4550d0475a62117631bb8b26d118516 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 2 Feb 2023 14:03:46 -0500 Subject: [PATCH] minor tweak --- packages/adapter-node/src/handler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/adapter-node/src/handler.js b/packages/adapter-node/src/handler.js index cd68657c1b52..650ab3ce6018 100644 --- a/packages/adapter-node/src/handler.js +++ b/packages/adapter-node/src/handler.js @@ -62,11 +62,11 @@ function serve_prerendered() { return handler(req, res, next); } - // redirect to counterpart - const counterpart_route = pathname.at(-1) === '/' ? pathname.slice(0, -1) : pathname + '/'; - if (counterpart_route && prerendered.has(counterpart_route)) { + // remove or add trailing slash as appropriate + let location = pathname.at(-1) === '/' ? pathname.slice(0, -1) : pathname + '/'; + if (prerendered.has(location)) { const search = req.url.split('?')[1]; - const location = `${counterpart_route}${search ? `?${search}` : ''}`; + if (search) location += `?${search}`; res.writeHead(308, { location }).end(); } else { next();