fix: language switcher always includes locale prefix in path

This commit is contained in:
Unchained
2026-03-24 08:17:30 +02:00
parent b70d46ff95
commit b488671bc3

View File

@@ -51,7 +51,7 @@ export default function Header({ locale = "sr" }: HeaderProps) {
}
document.cookie = `NEXT_LOCALE=${newLocale}; path=/; max-age=31536000`;
const pathWithoutLocale = pathname.replace(/^\/(sr|en|de|fr)/, "") || "/";
const newPath = newLocale === "sr" ? pathWithoutLocale : `/${newLocale}${pathWithoutLocale}`;
const newPath = `/${newLocale}${pathWithoutLocale}`;
router.push(newPath);
setLangDropdownOpen(false);
};