fix: language switcher always includes locale prefix in path
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user