Skip to content

Commit

Permalink
Fix double slash redirect (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
brookslybrand authored Aug 15, 2024
1 parent 35ad9a7 commit 2c15427
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/modules/http-utils/remove-slashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { redirect } from "@remix-run/node";
export async function removeTrailingSlashes(request: Request) {
let url = new URL(request.url);
if (url.pathname.endsWith("/") && url.pathname !== "/") {
throw redirect(url.pathname.slice(0, -1) + url.search);
url.pathname = url.pathname.slice(0, -1);
throw redirect(url.toString());
}
}

0 comments on commit 2c15427

Please sign in to comment.