Skip to content

Commit

Permalink
fix: oldUrl redirects not working if no trailing slash (denoland#757)
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister authored Aug 28, 2024
1 parent 9802039 commit 1854f54
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ server.use(async (req, next, info) => {
let res: Response;
try {
const url = new URL(req.url, "http://localhost:8000");
const redirect = REDIRECTS[url.pathname] || REDIRECTS[url.pathname + "/"];
const redirect = REDIRECTS[url.pathname] ||
(url.pathname.endsWith("/")
? REDIRECTS[url.pathname.slice(0, -1)]
: REDIRECTS[url.pathname + "/"]);
if (redirect) {
res = new Response(null, {
status: 301,
Expand Down

0 comments on commit 1854f54

Please sign in to comment.