Compare commits

...

1 Commits

Author SHA1 Message Date
SagarRajput-7
e69d054c41 fix: fixed the route match dropping the query search param after ? 2025-07-03 04:52:46 +05:30

View File

@@ -29,13 +29,23 @@ function RouteTab({
// Find the matching route for the current pathname
const currentRoute = routesWithParams.find((route) => {
const pathnameOnly = route.route.split('?')[0];
const routePattern = escapeRegExp(pathnameOnly).replace(
const [routePathname, routeQueryString = ''] = route.route.split('?');
const routePattern = escapeRegExp(routePathname).replace(
/\\:([a-zA-Z0-9_]+)/g,
'([^/]+)',
);
const regex = new RegExp(`^${routePattern}$`);
return regex.test(location.pathname);
const routeParams = new URLSearchParams(routeQueryString);
const locationParams = new URLSearchParams(location.search);
return (
regex.test(location.pathname) &&
Array.from(routeParams.entries()).every(
([key, value]) => locationParams.get(key) === value,
)
);
});
const onChange = (activeRoute: string): void => {