Skip to content

Commit

Permalink
fix: lang switch lost in root route of default locale (#1458)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachScript authored Feb 7, 2023
1 parent f6c5672 commit c5dc386
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/theme-default/slots/LangSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function getTargetLocalePath({
}) {
const clearPath =
'base' in current
? pathname.replace(current.base.replace(/\/$/, ''), '')
? // handle '/en-US/a' => '/a' or '/en-US' => '' => '/'
pathname.replace(current.base.replace(/\/$/, ''), '') || '/'
: pathname.replace(new RegExp(`${current.suffix}$`), '');

return 'base' in target
Expand Down

0 comments on commit c5dc386

Please sign in to comment.