Skip to content

Commit

Permalink
minor tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Feb 2, 2023
1 parent bbdd04c commit 4bbaf73
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4bbaf73

Please sign in to comment.