revamp template
This commit is contained in:
23
src/utils/Router.ts
Normal file
23
src/utils/Router.ts
Normal file
@ -0,0 +1,23 @@
|
||||
const getCurrentUrl = (path: string): string => {
|
||||
return path.split(/[?#]/)[0];
|
||||
};
|
||||
|
||||
const matchPath = (path: string, pathname: string): boolean => {
|
||||
const current = getCurrentUrl(path);
|
||||
|
||||
if (!current || !pathname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (current === pathname) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (current.includes(pathname)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export { getCurrentUrl, matchPath };
|
||||
Reference in New Issue
Block a user