Skip to content

Commit

Permalink
created helper function for normalizePath in routeUtils.ts to improve…
Browse files Browse the repository at this point in the history
… readability
  • Loading branch information
aadityanairaaq committed Dec 11, 2024
1 parent 5849313 commit 1dd19c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/utils/routeUtils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
export function isRouteActive(routePath: string): boolean {
const route = useRoute();

/**
* Normalize a given path by removing leading and trailing slashes.
*/
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);

Expand Down

0 comments on commit 1dd19c6

Please sign in to comment.