@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/mulan.esm.js
CHANGED
|
@@ -1400,20 +1400,32 @@ class MuRouter {
|
|
|
1400
1400
|
return { route, params: {} };
|
|
1401
1401
|
// Regex match for params e.g. /user/:id
|
|
1402
1402
|
for (const r of this.routes) {
|
|
1403
|
+
if (r.path === '*' || r.path === '/*')
|
|
1404
|
+
continue; // Skip wildcards for regex matching
|
|
1403
1405
|
const paramNames = [];
|
|
1404
1406
|
const regexPath = r.path.replace(/:([^/]+)/g, (_, key) => {
|
|
1405
1407
|
paramNames.push(key);
|
|
1406
1408
|
return '([^/]+)';
|
|
1407
1409
|
});
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1410
|
+
try {
|
|
1411
|
+
const match = new RegExp(`^${regexPath}$`).exec(hash);
|
|
1412
|
+
if (match) {
|
|
1413
|
+
const params = {};
|
|
1414
|
+
paramNames.forEach((name, i) => {
|
|
1415
|
+
// SECURE: Automatically sanitize all route parameters
|
|
1416
|
+
params[name] = Security.sanitize(match[i + 1]);
|
|
1417
|
+
});
|
|
1418
|
+
return { route: r, params };
|
|
1419
|
+
}
|
|
1416
1420
|
}
|
|
1421
|
+
catch (e) {
|
|
1422
|
+
// Ignore invalid regex paths
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
// Match wildcard / catch-all routes (*) as a fallback
|
|
1426
|
+
const wildcardRoute = this.routes.find((r) => r.path === '*' || r.path === '/*');
|
|
1427
|
+
if (wildcardRoute) {
|
|
1428
|
+
return { route: wildcardRoute, params: {} };
|
|
1417
1429
|
}
|
|
1418
1430
|
return { route: undefined, params: {} };
|
|
1419
1431
|
}
|