mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-18 07:56:56 +00:00
chore: fix the route tab regex error
This commit is contained in:
parent
5102cf2b7b
commit
aaaad8e0a2
@ -29,6 +29,11 @@ function RouteTab({
|
||||
|
||||
// Find the matching route for the current pathname
|
||||
const currentRoute = routesWithParams.find((route) => {
|
||||
try {
|
||||
const routePattern = route.route.replace(/:(\w+)/g, '([^/]+)');
|
||||
const regex = new RegExp(`^${routePattern}$`);
|
||||
return regex.test(location.pathname);
|
||||
} catch (error) {
|
||||
const pathnameOnly = route.route.split('?')[0];
|
||||
const routePattern = escapeRegExp(pathnameOnly).replace(
|
||||
/\\:([a-zA-Z0-9_]+)/g,
|
||||
@ -36,6 +41,7 @@ function RouteTab({
|
||||
);
|
||||
const regex = new RegExp(`^${routePattern}$`);
|
||||
return regex.test(location.pathname);
|
||||
}
|
||||
});
|
||||
|
||||
const onChange = (activeRoute: string): void => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user