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 type NavItemId = (typeof navItems)[number]["href"];
|
||||||
|
|
||||||
export function isActivePath(pathname: string, matchPrefix: string): boolean {
|
export function isActivePath(pathname: string, matchPrefix: string): boolean {
|
||||||
if (matchPrefix === "/dashboard") return pathname === "/dashboard";
|
// trailingSlash builds surface "/x/" via usePathname — normalize first.
|
||||||
return pathname.startsWith(matchPrefix);
|
const path = pathname.replace(/\/+$/, "") || "/";
|
||||||
|
if (matchPrefix === "/dashboard") return path === "/dashboard";
|
||||||
|
return path.startsWith(matchPrefix);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user