Skip to content

Commit c5dc386

Browse files
authored
fix: lang switch lost in root route of default locale (#1458)
1 parent f6c5672 commit c5dc386

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • src/client/theme-default/slots/LangSwitch

src/client/theme-default/slots/LangSwitch/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function getTargetLocalePath({
2323
}) {
2424
const clearPath =
2525
'base' in current
26-
? pathname.replace(current.base.replace(/\/$/, ''), '')
26+
? // handle '/en-US/a' => '/a' or '/en-US' => '' => '/'
27+
pathname.replace(current.base.replace(/\/$/, ''), '') || '/'
2728
: pathname.replace(new RegExp(`${current.suffix}$`), '');
2829

2930
return 'base' in target

0 commit comments

Comments
 (0)