Fix locale redirection logic in LocaleRedirector.astro

This commit is contained in:
TrèsAbhi authored and GitHub committed 2026-02-12 06:31:43 -06:00
1 parent a6cfb522b3
commit c24a2989fa
1 file changed
+3 -2
@@ -14,12 +14,13 @@
if ( if (
!isAPI && // not an api, duh! !isAPI && // not an api, duh!
localStorage.getItem("preferred-locale") !== null && // no preference, so probably google's crawler 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 = isI18nPath
? window.location.pathname.replace( ? window.location.pathname.replace(
`/${currentPath?.locale}`, `/${currentPath?.locale}`,
bestLocale === undefined ? "" : `/${bestLocale}`, bestLocale === locales.default ? "" : `/${bestLocale}`,
) )
: `${bestLocale}${window.location.pathname}`; : `${bestLocale}${window.location.pathname}`;
} }