Skip to content

Commit d3f3bc6

Browse files
author
Maledong
authored
fix: "Home" menu item misses the arrow when selected (#5171)
The "Home"'s default URL is "/”, this will cause a problem: When click the menu item, the arrow is missing. The solution is to ignore the last "/" and return you the URL as what it is.
1 parent 363de00 commit d3f3bc6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

util/linkWithLocale.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { UrlObject } from 'url';
22

3-
export const linkWithLocale = (locale: string) => (path: string | UrlObject) =>
4-
`/${locale}${path.toString()}`;
3+
export const linkWithLocale = (locale: string) => {
4+
return (path: string | UrlObject) => {
5+
path = path.toString();
6+
return path === '/' ? `/${locale}` : `/${locale}${path}`;
7+
};
8+
};

0 commit comments

Comments
 (0)