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