@mulanjs/mulanjs 1.0.1-dev.20260301170213 → 1.0.1-dev.20260302074037

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mulan.js CHANGED
@@ -2369,20 +2369,32 @@ class MuRouter {
2369
2369
  return { route, params: {} };
2370
2370
  // Regex match for params e.g. /user/:id
2371
2371
  for (const r of this.routes) {
2372
+ if (r.path === '*' || r.path === '/*')
2373
+ continue; // Skip wildcards for regex matching
2372
2374
  const paramNames = [];
2373
2375
  const regexPath = r.path.replace(/:([^/]+)/g, (_, key) => {
2374
2376
  paramNames.push(key);
2375
2377
  return '([^/]+)';
2376
2378
  });
2377
- const match = new RegExp(`^${regexPath}$`).exec(hash);
2378
- if (match) {
2379
- const params = {};
2380
- paramNames.forEach((name, i) => {
2381
- // SECURE: Automatically sanitize all route parameters
2382
- params[name] = sanitizer_1.Security.sanitize(match[i + 1]);
2383
- });
2384
- return { route: r, params };
2379
+ try {
2380
+ const match = new RegExp(`^${regexPath}$`).exec(hash);
2381
+ if (match) {
2382
+ const params = {};
2383
+ paramNames.forEach((name, i) => {
2384
+ // SECURE: Automatically sanitize all route parameters
2385
+ params[name] = sanitizer_1.Security.sanitize(match[i + 1]);
2386
+ });
2387
+ return { route: r, params };
2388
+ }
2385
2389
  }
2390
+ catch (e) {
2391
+ // Ignore invalid regex paths
2392
+ }
2393
+ }
2394
+ // Match wildcard / catch-all routes (*) as a fallback
2395
+ const wildcardRoute = this.routes.find((r) => r.path === '*' || r.path === '/*');
2396
+ if (wildcardRoute) {
2397
+ return { route: wildcardRoute, params: {} };
2386
2398
  }
2387
2399
  return { route: undefined, params: {} };
2388
2400
  }