There was an error while loading. Please reload this page.
1 parent baccb91 commit dd8be35Copy full SHA for dd8be35
1 file changed
src/i18n/utils.ts
@@ -18,8 +18,12 @@ export function useTranslations(lang?: Lang) {
18
};
19
}
20
21
+function normalizePath(path: string): string {
22
+ return path === '/' ? path : path.replace(/\/$/, '');
23
+}
24
+
25
export function isActive(linkPath: string, currentPath: string): boolean {
- const normalizedLink = linkPath.replace(/\/$/, '') || '/';
- const normalizedCurrent = currentPath.replace(/\/$/, '') || '/';
- return normalizedLink === normalizedCurrent;
26
+ const normalizedLink = normalizePath(linkPath);
27
+ const normalizedCurrent = normalizePath(currentPath);
28
+ return normalizedLink.endsWith(normalizedCurrent);
29
0 commit comments