diff --git a/packages/website/src/components/LocaleRedirector.astro b/packages/website/src/components/LocaleRedirector.astro index b7ed9ce26..e74e20b22 100644 --- a/packages/website/src/components/LocaleRedirector.astro +++ b/packages/website/src/components/LocaleRedirector.astro @@ -14,12 +14,13 @@ if ( !isAPI && // not an api, duh! localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler - bestLocale !== currentPath?.locale // we need to redirect + ((bestLocale === locales.default && currentPath !== undefined) || + (bestLocale !== currentPath)) ) { window.location.pathname = isI18nPath ? window.location.pathname.replace( `/${currentPath?.locale}`, - bestLocale === undefined ? "" : `/${bestLocale}`, + bestLocale === locales.default ? "" : `/${bestLocale}`, ) : `${bestLocale}${window.location.pathname}`; }