Skip to content

Commit 2fb7482

Browse files
committed
fixing the language selector
1 parent 48b326b commit 2fb7482

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/components/LanguageSelector.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const LanguageSelector = ({ className }) => {
1515

1616
// Node and the browser differs in the pathname as node has a trailing slash
1717
// This streamlines the pathname to not have a trailing slash.
18-
const realPath =
18+
const cleanPath =
1919
pathname[pathname.length - 1] === '/' ? pathname.slice(0, -1) : pathname;
2020

21-
const path = locale === 'en' ? realPath : realPath.replace(`${locale}/`, '');
21+
let path = locale === 'en' ? cleanPath : cleanPath.replace(`/${locale}`, '');
22+
if (path === '') {
23+
path = '/';
24+
}
2225

2326
const onToggle = () => {
2427
setOpen(!open);

0 commit comments

Comments
 (0)