hono 4.8.10 → 4.8.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.
@@ -5,7 +5,7 @@ var handle = (app, opts = {
5
5
  return (evt) => {
6
6
  evt.respondWith(
7
7
  (async () => {
8
- const res = await app.fetch(evt.request);
8
+ const res = await app.fetch(evt.request, evt);
9
9
  if (opts.fetch && res.status === 404) {
10
10
  return await opts.fetch(evt.request);
11
11
  }
@@ -27,7 +27,7 @@ const handle = (app, opts = {
27
27
  return (evt) => {
28
28
  evt.respondWith(
29
29
  (async () => {
30
- const res = await app.fetch(evt.request);
30
+ const res = await app.fetch(evt.request, evt);
31
31
  if (opts.fetch && res.status === 404) {
32
32
  return await opts.fetch(evt.request);
33
33
  }
@@ -68,6 +68,9 @@ class Node {
68
68
  const name = pattern[1];
69
69
  let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
70
70
  if (name && pattern[2]) {
71
+ if (regexpStr === ".*") {
72
+ throw PATH_ERROR;
73
+ }
71
74
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
72
75
  if (/\((?!\?:)/.test(regexpStr)) {
73
76
  throw PATH_ERROR;
@@ -133,10 +133,10 @@ class Node {
133
133
  }
134
134
  continue;
135
135
  }
136
- if (!part) {
136
+ const [key, name, matcher] = pattern;
137
+ if (!part && !(matcher instanceof RegExp)) {
137
138
  continue;
138
139
  }
139
- const [key, name, matcher] = pattern;
140
140
  const child = node.#children[key];
141
141
  const restPathString = parts.slice(i).join("/");
142
142
  if (matcher instanceof RegExp) {
@@ -45,6 +45,9 @@ var Node = class {
45
45
  const name = pattern[1];
46
46
  let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
47
47
  if (name && pattern[2]) {
48
+ if (regexpStr === ".*") {
49
+ throw PATH_ERROR;
50
+ }
48
51
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
49
52
  if (/\((?!\?:)/.test(regexpStr)) {
50
53
  throw PATH_ERROR;
@@ -111,10 +111,10 @@ var Node = class {
111
111
  }
112
112
  continue;
113
113
  }
114
- if (!part) {
114
+ const [key, name, matcher] = pattern;
115
+ if (!part && !(matcher instanceof RegExp)) {
115
116
  continue;
116
117
  }
117
- const [key, name, matcher] = pattern;
118
118
  const child = node.#children[key];
119
119
  const restPathString = parts.slice(i).join("/");
120
120
  if (matcher instanceof RegExp) {
@@ -92,10 +92,10 @@ interface NewResponse {
92
92
  * Interface for responding with a body.
93
93
  */
94
94
  interface BodyRespond {
95
- <U extends ContentfulStatusCode>(data: Data, status?: U, headers?: HeaderRecord): Response & TypedResponse<unknown, U, "body">;
96
- <U extends StatusCode>(data: null, status?: U, headers?: HeaderRecord): Response & TypedResponse<null, U, "body">;
97
- <U extends ContentfulStatusCode>(data: Data, init?: ResponseOrInit<U>): Response & TypedResponse<unknown, U, "body">;
98
- <U extends StatusCode>(data: null, init?: ResponseOrInit<U>): Response & TypedResponse<null, U, "body">;
95
+ <T extends Data, U extends ContentfulStatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, "body">;
96
+ <T extends Data, U extends ContentfulStatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<T, U, "body">;
97
+ <T extends null, U extends StatusCode>(data: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<null, U, "body">;
98
+ <T extends null, U extends StatusCode>(data: T, init?: ResponseOrInit<U>): Response & TypedResponse<null, U, "body">;
99
99
  }
100
100
  /**
101
101
  * Interface for responding with text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.8.10",
3
+ "version": "4.8.12",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",
@@ -656,7 +656,7 @@
656
656
  "nodejs"
657
657
  ],
658
658
  "devDependencies": {
659
- "@hono/eslint-config": "^1.0.2",
659
+ "@hono/eslint-config": "^2.0.3",
660
660
  "@hono/node-server": "^1.13.5",
661
661
  "@types/glob": "^8.1.0",
662
662
  "@types/jsdom": "^21.1.7",