hono 2.5.8 → 2.5.9
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.
|
@@ -40,6 +40,7 @@ function findParam(node, name) {
|
|
|
40
40
|
class Node {
|
|
41
41
|
constructor(method, handler, children) {
|
|
42
42
|
this.order = 0;
|
|
43
|
+
this.shouldCapture = false;
|
|
43
44
|
this.children = children || {};
|
|
44
45
|
this.methods = [];
|
|
45
46
|
this.name = "";
|
|
@@ -71,6 +72,7 @@ class Node {
|
|
|
71
72
|
const pattern = (0, import_url.getPattern)(p);
|
|
72
73
|
if (pattern) {
|
|
73
74
|
if (typeof pattern === "object") {
|
|
75
|
+
this.shouldCapture = true;
|
|
74
76
|
for (let j = 0, len2 = parentPatterns.length; j < len2; j++) {
|
|
75
77
|
if (typeof parentPatterns[j] === "object" && parentPatterns[j][1] === pattern[1]) {
|
|
76
78
|
throw new Error(errorMessage(pattern[1]));
|
|
@@ -85,6 +87,7 @@ class Node {
|
|
|
85
87
|
}
|
|
86
88
|
parentPatterns.push(...curNode.patterns);
|
|
87
89
|
curNode = curNode.children[p];
|
|
90
|
+
curNode.shouldCapture = this.shouldCapture;
|
|
88
91
|
}
|
|
89
92
|
if (!curNode.methods.length) {
|
|
90
93
|
curNode.methods = [];
|
|
@@ -157,6 +160,10 @@ class Node {
|
|
|
157
160
|
}
|
|
158
161
|
if (typeof name === "string" && !matched) {
|
|
159
162
|
params[name] = part;
|
|
163
|
+
} else {
|
|
164
|
+
if (node.children[part] && node.children[part].shouldCapture) {
|
|
165
|
+
params[name] = part;
|
|
166
|
+
}
|
|
160
167
|
}
|
|
161
168
|
}
|
|
162
169
|
}
|
|
@@ -12,6 +12,7 @@ export declare class Node<T> {
|
|
|
12
12
|
order: number;
|
|
13
13
|
name: string;
|
|
14
14
|
handlerSetCache: Record<string, HandlerSet<T>[]>;
|
|
15
|
+
shouldCapture: boolean;
|
|
15
16
|
constructor(method?: string, handler?: T, children?: Record<string, Node<T>>);
|
|
16
17
|
insert(method: string, path: string, handler: T): Node<T>;
|
|
17
18
|
private getHandlerSets;
|
|
@@ -18,6 +18,7 @@ function findParam(node, name) {
|
|
|
18
18
|
var Node = class {
|
|
19
19
|
constructor(method, handler, children) {
|
|
20
20
|
this.order = 0;
|
|
21
|
+
this.shouldCapture = false;
|
|
21
22
|
this.children = children || {};
|
|
22
23
|
this.methods = [];
|
|
23
24
|
this.name = "";
|
|
@@ -49,6 +50,7 @@ var Node = class {
|
|
|
49
50
|
const pattern = getPattern(p);
|
|
50
51
|
if (pattern) {
|
|
51
52
|
if (typeof pattern === "object") {
|
|
53
|
+
this.shouldCapture = true;
|
|
52
54
|
for (let j = 0, len2 = parentPatterns.length; j < len2; j++) {
|
|
53
55
|
if (typeof parentPatterns[j] === "object" && parentPatterns[j][1] === pattern[1]) {
|
|
54
56
|
throw new Error(errorMessage(pattern[1]));
|
|
@@ -63,6 +65,7 @@ var Node = class {
|
|
|
63
65
|
}
|
|
64
66
|
parentPatterns.push(...curNode.patterns);
|
|
65
67
|
curNode = curNode.children[p];
|
|
68
|
+
curNode.shouldCapture = this.shouldCapture;
|
|
66
69
|
}
|
|
67
70
|
if (!curNode.methods.length) {
|
|
68
71
|
curNode.methods = [];
|
|
@@ -135,6 +138,10 @@ var Node = class {
|
|
|
135
138
|
}
|
|
136
139
|
if (typeof name === "string" && !matched) {
|
|
137
140
|
params[name] = part;
|
|
141
|
+
} else {
|
|
142
|
+
if (node.children[part] && node.children[part].shouldCapture) {
|
|
143
|
+
params[name] = part;
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
146
|
}
|
|
140
147
|
}
|