Skip to content

Commit

Permalink
fix(removeTrailingSlashes): include origin when redirecting
Browse files Browse the repository at this point in the history
closes #72

Signed-off-by: Logan McAnsh <[email protected]>
  • Loading branch information
mcansh committed Jul 26, 2023
1 parent 4450a22 commit 179b4d5
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 179b4d5

Please sign in to comment.