hono 3.12.4 → 3.12.5

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.
@@ -70,7 +70,7 @@ class Node {
70
70
  const m = {};
71
71
  const handlerSet = {
72
72
  handler,
73
- possibleKeys,
73
+ possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
74
74
  name: this.name,
75
75
  score: this.order
76
76
  };
@@ -78,15 +78,18 @@ class Node {
78
78
  curNode.methods.push(m);
79
79
  return curNode;
80
80
  }
81
- gHSets(node, method, params) {
81
+ gHSets(node, method, nodeParams, params) {
82
82
  const handlerSets = [];
83
83
  for (let i = 0, len = node.methods.length; i < len; i++) {
84
84
  const m = node.methods[i];
85
85
  const handlerSet = m[method] || m[import_router.METHOD_NAME_ALL];
86
+ const processedSet = {};
86
87
  if (handlerSet !== void 0) {
87
88
  handlerSet.params = {};
88
- handlerSet.possibleKeys.map((key) => {
89
- handlerSet.params[key] = params[key];
89
+ handlerSet.possibleKeys.forEach((key) => {
90
+ const processed = processedSet[handlerSet.name];
91
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
92
+ processedSet[handlerSet.name] = true;
90
93
  });
91
94
  handlerSets.push(handlerSet);
92
95
  }
@@ -96,6 +99,7 @@ class Node {
96
99
  search(method, path) {
97
100
  const handlerSets = [];
98
101
  this.params = {};
102
+ const params = {};
99
103
  const curNode = this;
100
104
  let curNodes = [curNode];
101
105
  const parts = (0, import_url.splitPath)(path);
@@ -110,20 +114,19 @@ class Node {
110
114
  nextNode.params = node.params;
111
115
  if (isLast === true) {
112
116
  if (nextNode.children["*"]) {
113
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
117
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
114
118
  }
115
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
119
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
116
120
  } else {
117
121
  tempNodes.push(nextNode);
118
122
  }
119
123
  }
120
124
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
121
- const params = {};
122
125
  const pattern = node.patterns[k];
123
126
  if (pattern === "*") {
124
127
  const astNode = node.children["*"];
125
128
  if (astNode) {
126
- handlerSets.push(...this.gHSets(astNode, method, node.params));
129
+ handlerSets.push(...this.gHSets(astNode, method, node.params, {}));
127
130
  tempNodes.push(astNode);
128
131
  }
129
132
  continue;
@@ -135,18 +138,16 @@ class Node {
135
138
  const restPathString = parts.slice(i).join("/");
136
139
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
137
140
  params[name] = restPathString;
138
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
141
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
139
142
  continue;
140
143
  }
141
144
  if (matcher === true || matcher instanceof RegExp && matcher.test(part)) {
142
145
  if (typeof key === "string") {
143
146
  params[name] = part;
144
147
  if (isLast === true) {
145
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
148
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
146
149
  if (child.children["*"]) {
147
- handlerSets.push(
148
- ...this.gHSets(child.children["*"], method, { ...params, ...node.params })
149
- );
150
+ handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
150
151
  }
151
152
  } else {
152
153
  child.params = { ...params };
@@ -161,7 +162,7 @@ class Node {
161
162
  const results = handlerSets.sort((a, b) => {
162
163
  return a.score - b.score;
163
164
  });
164
- return [results.map(({ handler, params }) => [handler, params])];
165
+ return [results.map(({ handler, params: params2 }) => [handler, params2])];
165
166
  }
166
167
  }
167
168
  // Annotate the CommonJS export names for ESM import in node:
@@ -48,7 +48,7 @@ var Node = class {
48
48
  const m = {};
49
49
  const handlerSet = {
50
50
  handler,
51
- possibleKeys,
51
+ possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
52
52
  name: this.name,
53
53
  score: this.order
54
54
  };
@@ -56,15 +56,18 @@ var Node = class {
56
56
  curNode.methods.push(m);
57
57
  return curNode;
58
58
  }
59
- gHSets(node, method, params) {
59
+ gHSets(node, method, nodeParams, params) {
60
60
  const handlerSets = [];
61
61
  for (let i = 0, len = node.methods.length; i < len; i++) {
62
62
  const m = node.methods[i];
63
63
  const handlerSet = m[method] || m[METHOD_NAME_ALL];
64
+ const processedSet = {};
64
65
  if (handlerSet !== void 0) {
65
66
  handlerSet.params = {};
66
- handlerSet.possibleKeys.map((key) => {
67
- handlerSet.params[key] = params[key];
67
+ handlerSet.possibleKeys.forEach((key) => {
68
+ const processed = processedSet[handlerSet.name];
69
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
70
+ processedSet[handlerSet.name] = true;
68
71
  });
69
72
  handlerSets.push(handlerSet);
70
73
  }
@@ -74,6 +77,7 @@ var Node = class {
74
77
  search(method, path) {
75
78
  const handlerSets = [];
76
79
  this.params = {};
80
+ const params = {};
77
81
  const curNode = this;
78
82
  let curNodes = [curNode];
79
83
  const parts = splitPath(path);
@@ -88,20 +92,19 @@ var Node = class {
88
92
  nextNode.params = node.params;
89
93
  if (isLast === true) {
90
94
  if (nextNode.children["*"]) {
91
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
95
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
92
96
  }
93
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
97
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
94
98
  } else {
95
99
  tempNodes.push(nextNode);
96
100
  }
97
101
  }
98
102
  for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
99
- const params = {};
100
103
  const pattern = node.patterns[k];
101
104
  if (pattern === "*") {
102
105
  const astNode = node.children["*"];
103
106
  if (astNode) {
104
- handlerSets.push(...this.gHSets(astNode, method, node.params));
107
+ handlerSets.push(...this.gHSets(astNode, method, node.params, {}));
105
108
  tempNodes.push(astNode);
106
109
  }
107
110
  continue;
@@ -113,18 +116,16 @@ var Node = class {
113
116
  const restPathString = parts.slice(i).join("/");
114
117
  if (matcher instanceof RegExp && matcher.test(restPathString)) {
115
118
  params[name] = restPathString;
116
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
119
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
117
120
  continue;
118
121
  }
119
122
  if (matcher === true || matcher instanceof RegExp && matcher.test(part)) {
120
123
  if (typeof key === "string") {
121
124
  params[name] = part;
122
125
  if (isLast === true) {
123
- handlerSets.push(...this.gHSets(child, method, { ...params, ...node.params }));
126
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
124
127
  if (child.children["*"]) {
125
- handlerSets.push(
126
- ...this.gHSets(child.children["*"], method, { ...params, ...node.params })
127
- );
128
+ handlerSets.push(...this.gHSets(child.children["*"], method, node.params, params));
128
129
  }
129
130
  } else {
130
131
  child.params = { ...params };
@@ -139,7 +140,7 @@ var Node = class {
139
140
  const results = handlerSets.sort((a, b) => {
140
141
  return a.score - b.score;
141
142
  });
142
- return [results.map(({ handler, params }) => [handler, params])];
143
+ return [results.map(({ handler, params: params2 }) => [handler, params2])];
143
144
  }
144
145
  };
145
146
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.4",
3
+ "version": "3.12.5",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",