hono 3.12.3 → 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
  }
@@ -95,8 +98,8 @@ class Node {
95
98
  }
96
99
  search(method, path) {
97
100
  const handlerSets = [];
98
- const params = {};
99
101
  this.params = {};
102
+ const params = {};
100
103
  const curNode = this;
101
104
  let curNodes = [curNode];
102
105
  const parts = (0, import_url.splitPath)(path);
@@ -111,9 +114,9 @@ class Node {
111
114
  nextNode.params = node.params;
112
115
  if (isLast === true) {
113
116
  if (nextNode.children["*"]) {
114
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
117
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
115
118
  }
116
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
119
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
117
120
  } else {
118
121
  tempNodes.push(nextNode);
119
122
  }
@@ -123,7 +126,7 @@ class Node {
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 };
@@ -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
  }
@@ -73,8 +76,8 @@ var Node = class {
73
76
  }
74
77
  search(method, path) {
75
78
  const handlerSets = [];
76
- const params = {};
77
79
  this.params = {};
80
+ const params = {};
78
81
  const curNode = this;
79
82
  let curNodes = [curNode];
80
83
  const parts = splitPath(path);
@@ -89,9 +92,9 @@ var Node = class {
89
92
  nextNode.params = node.params;
90
93
  if (isLast === true) {
91
94
  if (nextNode.children["*"]) {
92
- handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params));
95
+ handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, {}));
93
96
  }
94
- handlerSets.push(...this.gHSets(nextNode, method, node.params));
97
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, {}));
95
98
  } else {
96
99
  tempNodes.push(nextNode);
97
100
  }
@@ -101,7 +104,7 @@ var Node = class {
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.3",
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",
@@ -22,9 +22,9 @@
22
22
  "test:all": "yarn test && yarn test:deno && yarn test:bun && yarn test:fastly && yarn test:lagon && yarn test:node && yarn test:wrangler && yarn test:lambda && yarn test:lambda-edge",
23
23
  "lint": "eslint --ext js,ts src runtime_tests",
24
24
  "lint:fix": "eslint --ext js,ts src runtime_tests --fix",
25
- "format": "prettier --check 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",
26
- "format:fix": "prettier --write 'src/**/*.{js,ts}' 'runtime_tests/**/*.{js,ts}'",
27
- "denoify": "rimraf deno_dist && denoify && rimraf 'deno_dist/**/*.test.{ts,tsx}'",
25
+ "format": "prettier --check \"src/**/*.{js,ts}\" \"runtime_tests/**/*.{js,ts}\"",
26
+ "format:fix": "prettier --write \"src/**/*.{js,ts}\" \"runtime_tests/**/*.{js,ts}\"",
27
+ "denoify": "rimraf deno_dist && denoify && rimraf \"deno_dist/**/*.test.{ts,tsx}\"",
28
28
  "copy:package.cjs.json": "cp ./package.cjs.json ./dist/cjs/package.json && cp ./package.cjs.json ./dist/types/package.json ",
29
29
  "build": "rimraf dist && tsx ./build.ts && yarn copy:package.cjs.json",
30
30
  "postbuild": "publint",