Skip to content

Commit

Permalink
chore: update the matchPath
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter committed Jan 27, 2025
1 parent 51f815f commit cb8422f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/theme-default/src/logic/useSidebarData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ interface SidebarData {
* @param pattern /zh/guide
* @param currentPathname /base/zh/guide/getting-started
*/
const matchPath = (pattern: string, currentPathname: string): boolean => {
const prefix = withBase(addTrailingSlash(pattern));
return currentPathname.startsWith(prefix);
export const matchPath = (
pattern: string,
currentPathname: string,
): boolean => {
const prefix = withBase(pattern);
if (prefix === currentPathname) {
return true;
}
const prefixWithTrailingSlash = addTrailingSlash(pattern);
return currentPathname.startsWith(prefixWithTrailingSlash);
};

const match = (
Expand Down

0 comments on commit cb8422f

Please sign in to comment.