From b79372dfc9878421004cd3ea05dcef11a0817844 Mon Sep 17 00:00:00 2001 From: Clembs Date: Sun, 30 Nov 2025 01:08:05 +0100 Subject: [PATCH] fix: include search params when rerouting --- src/pages/[...route].astro | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/[...route].astro b/src/pages/[...route].astro index d7cb1ee..c7c8f29 100644 --- a/src/pages/[...route].astro +++ b/src/pages/[...route].astro @@ -3,10 +3,10 @@ export const prerender = false; import { + defaultLocale, + localeCodes, removeTrailingSlash, useTranslatedPaths, - localeCodes, - defaultLocale, } from "@i18n"; import { handleRedirect } from "../redirects"; @@ -22,7 +22,8 @@ const [_, langParam] = Astro.url.pathname.split("/"); // if there's no lang parameter, detect language and redirect if (!langParam || !localeCodes.includes(langParam)) { const headerLang = Astro.request.headers.get("Accept-Language"); - const path = removeTrailingSlash(Astro.url.pathname); + const pathnameWithParams = Astro.url.href.replace(Astro.url.origin, ""); + const path = removeTrailingSlash(pathnameWithParams); // if the lang is french, serve the content in french if (headerLang?.includes("fr")) { -- 2.51.2