From 4f633b379460dbd052ca3dbe32df26b9fde932c6 Mon Sep 17 00:00:00 2001 From: mlogclub Date: Fri, 24 Apr 2026 21:31:17 +0800 Subject: [PATCH] fix(nav-main): improve path normalization in isActive function --- web/components/nav-main.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/components/nav-main.tsx b/web/components/nav-main.tsx index 5c08c19..6165ef3 100644 --- a/web/components/nav-main.tsx +++ b/web/components/nav-main.tsx @@ -26,10 +26,15 @@ export function NavMain({ const pathname = usePathname() const isActive = (itemUrl: string) => { - if (itemUrl === "/") { - return pathname === itemUrl + const normalizePath = (path: string) => + path !== "/" ? path.replace(/\/+$/, "") : path + const currentPath = normalizePath(pathname) + const targetPath = normalizePath(itemUrl) + + if (targetPath === "/" || targetPath === "/dashboard") { + return currentPath === targetPath } - return pathname === itemUrl || pathname.startsWith(itemUrl + "/") + return currentPath === targetPath || currentPath.startsWith(targetPath + "/") } return (