chore: create isPathActive helper

This commit is contained in:
ValdiANS
2025-12-04 22:45:57 +07:00
parent 48dd6d7218
commit ae4c17b391
+13
View File
@@ -119,3 +119,16 @@ export const convertRowSelectionObjToArr = (
return result;
};
export const isPathActive = (pathname: string, link?: string) => {
if (!link) return false;
const splittedPathname = pathname.split('/');
const splittedLink = link.split('/');
const isActiveLinkValid = splittedLink.every((linkChunk, idx) => {
return linkChunk === splittedPathname[idx];
});
return pathname.startsWith(link) && isActiveLinkValid;
};