@noxfly/noxus 3.0.0-dev.11 → 3.0.0-dev.12
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/main.d.mts +10 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +17 -3
- package/dist/main.js.map +1 -1
- package/dist/main.mjs +17 -3
- package/dist/main.mjs.map +1 -1
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1254,17 +1254,31 @@ var _Router = class _Router {
|
|
|
1254
1254
|
throw new NotFoundException(`No route matches ${request.method} ${request.path}`);
|
|
1255
1255
|
}
|
|
1256
1256
|
async tryLoadLazyRoute(requestPath) {
|
|
1257
|
-
const
|
|
1257
|
+
const normalized = requestPath.replace(/^\/+/, "");
|
|
1258
1258
|
for (const [prefix, entry] of this.lazyRoutes) {
|
|
1259
1259
|
if (entry.loaded) continue;
|
|
1260
|
-
|
|
1261
|
-
if (normalized === prefix || normalized.startsWith(prefix + "/") || firstSegment === prefix) {
|
|
1260
|
+
if (this.pathHasPrefix(normalized, prefix)) {
|
|
1262
1261
|
if (!entry.loading) entry.loading = this.loadLazyModule(prefix, entry);
|
|
1263
1262
|
await entry.loading;
|
|
1264
1263
|
return;
|
|
1265
1264
|
}
|
|
1266
1265
|
}
|
|
1267
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Returns true when `requestPath` starts with `prefix`, treating `:param`
|
|
1269
|
+
* segments in the prefix as single-segment wildcards.
|
|
1270
|
+
*
|
|
1271
|
+
* @example
|
|
1272
|
+
* pathHasPrefix('contact/123/notes', 'contact/:id/notes') // true
|
|
1273
|
+
* pathHasPrefix('contact/123/notes/get', 'contact/:id/notes') // true
|
|
1274
|
+
* pathHasPrefix('contact/123', 'contact/:id/notes') // false
|
|
1275
|
+
*/
|
|
1276
|
+
pathHasPrefix(requestPath, prefix) {
|
|
1277
|
+
const reqSegments = requestPath.split("/");
|
|
1278
|
+
const prefixSegments = prefix.split("/");
|
|
1279
|
+
if (reqSegments.length < prefixSegments.length) return false;
|
|
1280
|
+
return prefixSegments.every((seg, i) => seg.startsWith(":") || seg === reqSegments[i]);
|
|
1281
|
+
}
|
|
1268
1282
|
loadLazyModule(prefix, entry) {
|
|
1269
1283
|
const task = this.lazyLoadLock.then(async () => {
|
|
1270
1284
|
const t0 = performance.now();
|