Skip to content

Commit 5f17ba5

Browse files
committed
fix(i18n): always return the path without local
1 parent 8863812 commit 5f17ba5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useMatches } from 'react-router-dom';
2+
import i18n from 'src/i18n';
23

34
export const usePathWithoutLocale = () => {
4-
const [locale, ...matches] = useMatches();
5+
const [, ...matches] = useMatches();
6+
const currentLanguage = i18n.language === 'en' ? '' : `/${i18n.language}`;
7+
58
if (!matches.length) return false;
6-
return matches[matches.length - 1].pathname.replace(locale.pathname, '');
9+
10+
return matches[matches.length - 1].pathname.replace(currentLanguage, '');
711
};

0 commit comments

Comments
 (0)