@sourceregistry/node-webserver 1.6.0 → 1.6.1
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/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +22 -7
- package/dist/index.es.js.map +1 -1
- package/dist/types/router.d.ts +2 -0
- package/package.json +11 -8
package/dist/index.es.js
CHANGED
|
@@ -603,21 +603,36 @@ var H = [
|
|
|
603
603
|
return r;
|
|
604
604
|
}
|
|
605
605
|
async handleNestedRouters(e, t) {
|
|
606
|
-
let n = [...this._nestedRouters].sort((e, t) => t.priority - e.priority);
|
|
607
|
-
for (let
|
|
608
|
-
let n = t.match(
|
|
606
|
+
let n = [...this._nestedRouters].sort((e, t) => t.priority - e.priority), r = e.request.method;
|
|
607
|
+
for (let i of n) {
|
|
608
|
+
let n = t.match(i.regex);
|
|
609
609
|
if (!n || n.index !== 0) continue;
|
|
610
|
-
let
|
|
610
|
+
let a = n[0], o = t.slice(a.length) || "/";
|
|
611
|
+
if (!i.router.hasHttpMatchAtPath(r, o)) continue;
|
|
612
|
+
let s = this.extractPrefixParams(i, a), c = {
|
|
611
613
|
...e,
|
|
612
614
|
params: {
|
|
613
615
|
...e.params,
|
|
614
|
-
...
|
|
616
|
+
...s
|
|
615
617
|
}
|
|
616
|
-
},
|
|
617
|
-
if (
|
|
618
|
+
}, l = await this.applyMiddlewaresWithList(c, i.middlewares, async () => await i.router.handleAtPath(c, o));
|
|
619
|
+
if (l) return l;
|
|
618
620
|
}
|
|
619
621
|
return null;
|
|
620
622
|
}
|
|
623
|
+
hasHttpMatchAtPath(e, t) {
|
|
624
|
+
if (this.hasLocalPathMatch(t, e)) return !0;
|
|
625
|
+
for (let n of this._nestedRouters) {
|
|
626
|
+
let r = t.match(n.regex);
|
|
627
|
+
if (!r || r.index !== 0) continue;
|
|
628
|
+
let i = r[0], a = t.slice(i.length) || "/";
|
|
629
|
+
if (n.router.hasHttpMatchAtPath(e, a)) return !0;
|
|
630
|
+
}
|
|
631
|
+
return !1;
|
|
632
|
+
}
|
|
633
|
+
hasLocalPathMatch(e, t) {
|
|
634
|
+
return this._routes.some((n) => n.regex.test(e) ? t === "HEAD" ? n.method === "HEAD" || n.method === "GET" : !0 : !1);
|
|
635
|
+
}
|
|
621
636
|
async handleLocalRoutes(e, t, n) {
|
|
622
637
|
let r = /* @__PURE__ */ new Set(), i = !1;
|
|
623
638
|
for (let a of this._routes) {
|