We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db68593 commit eecada4Copy full SHA for eecada4
1 file changed
frontend/src/components/LocaleToggle.tsx
@@ -8,8 +8,13 @@ export function LocaleToggle() {
8
9
const otherLocale = locale === "ko" ? "en" : "ko";
10
const toggleLabel = locale === "ko" ? "Switch to English" : "한국어로 전환";
11
- // Replace /{locale}/ prefix in pathname
12
- const newPath = pathname.replace(`/${locale}`, `/${otherLocale}`);
+ const normalizedPath = pathname.startsWith(`/${locale}`)
+ ? pathname
13
+ : `/${locale}${pathname}`;
14
+ const safePath = normalizedPath.replace(new RegExp(`^/${locale}(?=/|$)`), `/${otherLocale}`);
15
+
16
+ // Replace /{locale} prefix in pathname
17
+ const newPath = safePath;
18
19
return (
20
<a
0 commit comments