mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: redirect
This commit is contained in:
1 parent
a359897a2a
commit
61d1ebbad6
1 file changed
+3
-3
@@ -7,18 +7,18 @@
|
|||||||
window.location.pathname.startsWith(`/${locale}`)
|
window.location.pathname.startsWith(`/${locale}`)
|
||||||
);
|
);
|
||||||
const bestLocale = getBestLocale();
|
const bestLocale = getBestLocale();
|
||||||
const currentPathLocale = locales.supported.find(({ locale }) =>
|
const currentPath = locales.supported.find(({ locale }) =>
|
||||||
window.location.pathname.startsWith(`/${locale}`)
|
window.location.pathname.startsWith(`/${locale}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
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 !== currentPathLocale // we need to redirect
|
bestLocale !== currentPath?.locale // we need to redirect
|
||||||
) {
|
) {
|
||||||
window.location.pathname = isI18nPath
|
window.location.pathname = isI18nPath
|
||||||
? window.location.pathname.replace(
|
? window.location.pathname.replace(
|
||||||
`/${currentPathLocale}`,
|
`/${currentPath?.locale}`,
|
||||||
bestLocale === undefined ? "" : `/${bestLocale}`
|
bestLocale === undefined ? "" : `/${bestLocale}`
|
||||||
)
|
)
|
||||||
: `/${bestLocale}${window.location.pathname}`;
|
: `/${bestLocale}${window.location.pathname}`;
|
||||||
|
|||||||
Reference in new issue
Block a user