fix(frontend): normalisasi trailing slash pada isActivePath agar nav aktif terdeteksi
This commit is contained in:
@@ -75,6 +75,8 @@ export const mobileNavItems: NavItem[] = navItems.filter((item) =>
|
||||
export type NavItemId = (typeof navItems)[number]["href"];
|
||||
|
||||
export function isActivePath(pathname: string, matchPrefix: string): boolean {
|
||||
if (matchPrefix === "/dashboard") return pathname === "/dashboard";
|
||||
return pathname.startsWith(matchPrefix);
|
||||
// trailingSlash builds surface "/x/" via usePathname — normalize first.
|
||||
const path = pathname.replace(/\/+$/, "") || "/";
|
||||
if (matchPrefix === "/dashboard") return path === "/dashboard";
|
||||
return path.startsWith(matchPrefix);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user