@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.esm.js +20 -8
- package/dist/mulan.esm.js.map +1 -1
- package/dist/mulan.js +20 -8
- package/dist/mulan.js.map +1 -1
- package/dist/router/index.js +20 -8
- package/package.json +1 -1
package/dist/router/index.js
CHANGED
|
@@ -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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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