From 61d1ebbad6fbd9fb0e1c6c919578c129dbfee2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:35:47 -0500 Subject: [PATCH] fix: redirect --- packages/website/src/components/LocaleRedirector.astro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/website/src/components/LocaleRedirector.astro b/packages/website/src/components/LocaleRedirector.astro index d66b93723..b234ba4f3 100644 --- a/packages/website/src/components/LocaleRedirector.astro +++ b/packages/website/src/components/LocaleRedirector.astro @@ -7,18 +7,18 @@ window.location.pathname.startsWith(`/${locale}`) ); const bestLocale = getBestLocale(); - const currentPathLocale = locales.supported.find(({ locale }) => + const currentPath = locales.supported.find(({ locale }) => window.location.pathname.startsWith(`/${locale}`) ); if ( !isAPI && // not an api, duh! localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler - bestLocale !== currentPathLocale // we need to redirect + bestLocale !== currentPath?.locale // we need to redirect ) { window.location.pathname = isI18nPath ? window.location.pathname.replace( - `/${currentPathLocale}`, + `/${currentPath?.locale}`, bestLocale === undefined ? "" : `/${bestLocale}` ) : `/${bestLocale}${window.location.pathname}`;