From 2c154277518c1599656a948059b82b02f22c7282 Mon Sep 17 00:00:00 2001 From: Brooks Lybrand Date: Thu, 15 Aug 2024 11:08:07 -0500 Subject: [PATCH] Fix double slash redirect (#117) --- app/modules/http-utils/remove-slashes.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/modules/http-utils/remove-slashes.ts b/app/modules/http-utils/remove-slashes.ts index 4cfe90b5..49f04974 100644 --- a/app/modules/http-utils/remove-slashes.ts +++ b/app/modules/http-utils/remove-slashes.ts @@ -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()); } }