Skip to content

Commit cb8422f

Browse files
committed
chore: update the matchPath
1 parent 51f815f commit cb8422f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/theme-default/src/logic/useSidebarData.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ interface SidebarData {
1919
* @param pattern /zh/guide
2020
* @param currentPathname /base/zh/guide/getting-started
2121
*/
22-
const matchPath = (pattern: string, currentPathname: string): boolean => {
23-
const prefix = withBase(addTrailingSlash(pattern));
24-
return currentPathname.startsWith(prefix);
22+
export const matchPath = (
23+
pattern: string,
24+
currentPathname: string,
25+
): boolean => {
26+
const prefix = withBase(pattern);
27+
if (prefix === currentPathname) {
28+
return true;
29+
}
30+
const prefixWithTrailingSlash = addTrailingSlash(pattern);
31+
return currentPathname.startsWith(prefixWithTrailingSlash);
2532
};
2633

2734
const match = (

0 commit comments

Comments
 (0)