@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.
@@ -64,20 +64,32 @@ class MuRouter {
64
64
  return { route, params: {} };
65
65
  // Regex match for params e.g. /user/:id
66
66
  for (const r of this.routes) {
67
+ if (r.path === '*' || r.path === '/*')
68
+ continue; // Skip wildcards for regex matching
67
69
  const paramNames = [];
68
70
  const regexPath = r.path.replace(/:([^/]+)/g, (_, key) => {
69
71
  paramNames.push(key);
70
72
  return '([^/]+)';
71
73
  });
72
- const match = new RegExp(`^${regexPath}$`).exec(hash);
73
- if (match) {
74
- const params = {};
75
- paramNames.forEach((name, i) => {
76
- // SECURE: Automatically sanitize all route parameters
77
- params[name] = sanitizer_1.Security.sanitize(match[i + 1]);
78
- });
79
- return { route: r, params };
74
+ try {
75
+ const match = new RegExp(`^${regexPath}$`).exec(hash);
76
+ if (match) {
77
+ const params = {};
78
+ paramNames.forEach((name, i) => {
79
+ // SECURE: Automatically sanitize all route parameters
80
+ params[name] = sanitizer_1.Security.sanitize(match[i + 1]);
81
+ });
82
+ return { route: r, params };
83
+ }
80
84
  }
85
+ catch (e) {
86
+ // Ignore invalid regex paths
87
+ }
88
+ }
89
+ // Match wildcard / catch-all routes (*) as a fallback
90
+ const wildcardRoute = this.routes.find((r) => r.path === '*' || r.path === '/*');
91
+ if (wildcardRoute) {
92
+ return { route: wildcardRoute, params: {} };
81
93
  }
82
94
  return { route: undefined, params: {} };
83
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulanjs/mulanjs",
3
- "version": "1.0.1-dev.20260301170213",
3
+ "version": "1.0.1-dev.20260302074037",
4
4
  "description": "A powerful, secure, and enterprise-grade JavaScript framework.",
5
5
  "main": "dist/mulan.js",
6
6
  "module": "dist/mulan.esm.js",