From 1dd19c60a397cf24eff892b7674fde65efa76bb3 Mon Sep 17 00:00:00 2001 From: aaditya nair Date: Wed, 11 Dec 2024 21:51:34 +0300 Subject: [PATCH] created helper function for normalizePath in routeUtils.ts to improve readability --- frontend/utils/routeUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/utils/routeUtils.ts b/frontend/utils/routeUtils.ts index d05c18098..ea9befffe 100644 --- a/frontend/utils/routeUtils.ts +++ b/frontend/utils/routeUtils.ts @@ -1,5 +1,4 @@ -export function isRouteActive(routePath: string): boolean { - const route = useRoute(); + /** * Normalize a given path by removing leading and trailing slashes. */ @@ -7,6 +6,9 @@ function normalizePath(path: string): string { return path.replace(/^\/|\/$/g, ''); } +export function isRouteActive(routePath: string): boolean { + const route = useRoute(); + const currentPath = normalizePath(route.path); const targetPath = normalizePath(routePath);