hono 3.12.2 → 3.12.3

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.
@@ -30,7 +30,8 @@ var createResult = async (res) => {
30
30
  return {
31
31
  status: res.status.toString(),
32
32
  headers: convertHeaders(res.headers),
33
- body
33
+ body,
34
+ ...isBase64Encoded ? { bodyEncoding: "base64" } : {}
34
35
  };
35
36
  };
36
37
  var createRequest = (event) => {
@@ -59,7 +59,8 @@ const createResult = async (res) => {
59
59
  return {
60
60
  status: res.status.toString(),
61
61
  headers: convertHeaders(res.headers),
62
- body
62
+ body,
63
+ ...isBase64Encoded ? { bodyEncoding: "base64" } : {}
63
64
  };
64
65
  };
65
66
  const createRequest = (event) => {
@@ -241,9 +241,17 @@ class Context {
241
241
  __privateSet(this, _isFresh, false);
242
242
  if (__privateGet(this, _res) && _res2) {
243
243
  __privateGet(this, _res).headers.delete("content-type");
244
- __privateGet(this, _res).headers.forEach((v, k) => {
245
- _res2.headers.set(k, v);
246
- });
244
+ for (const [k, v] of __privateGet(this, _res).headers.entries()) {
245
+ if (k === "set-cookie") {
246
+ const cookies = __privateGet(this, _res).headers.getSetCookie();
247
+ _res2.headers.delete("set-cookie");
248
+ for (const cookie of cookies) {
249
+ _res2.headers.append("set-cookie", cookie);
250
+ }
251
+ } else {
252
+ _res2.headers.set(k, v);
253
+ }
254
+ }
247
255
  }
248
256
  __privateSet(this, _res, _res2);
249
257
  this.finalized = true;
@@ -22,6 +22,7 @@ __export(router_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(router_exports);
24
24
  var import_router = require("../../router");
25
+ var import_url = require("../../utils/url");
25
26
  const emptyParams = {};
26
27
  const splitPathRe = /\/(:\w+(?:{[^}]+})?)|\/[^\/\?]+|(\?)/g;
27
28
  const splitByStarRe = /\*/;
@@ -31,12 +32,10 @@ class LinearRouter {
31
32
  this.routes = [];
32
33
  }
33
34
  add(method, path, handler) {
34
- if (path.charCodeAt(path.length - 1) === 63) {
35
- this.routes.push([method, path.slice(0, -1), handler]);
36
- this.routes.push([method, path.replace(/\/[^/]+$/, ""), handler]);
37
- } else {
38
- this.routes.push([method, path, handler]);
39
- }
35
+ ;
36
+ ((0, import_url.checkOptionalParameter)(path) || [path]).forEach((p) => {
37
+ this.routes.push([method, p, handler]);
38
+ });
40
39
  }
41
40
  match(method, path) {
42
41
  const handlers = [];
@@ -167,10 +167,7 @@ class RegExpRouter {
167
167
  (_a2 = routes[m])[path2] || (_a2[path2] = [
168
168
  ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[import_router.METHOD_NAME_ALL], path2) || []
169
169
  ]);
170
- routes[m][path2].push([
171
- handler,
172
- paths.length === 2 && i === 0 ? paramCount - 1 : paramCount
173
- ]);
170
+ routes[m][path2].push([handler, paramCount - len + i + 1]);
174
171
  }
175
172
  });
176
173
  }
package/dist/context.js CHANGED
@@ -219,9 +219,17 @@ var Context = class {
219
219
  __privateSet(this, _isFresh, false);
220
220
  if (__privateGet(this, _res) && _res2) {
221
221
  __privateGet(this, _res).headers.delete("content-type");
222
- __privateGet(this, _res).headers.forEach((v, k) => {
223
- _res2.headers.set(k, v);
224
- });
222
+ for (const [k, v] of __privateGet(this, _res).headers.entries()) {
223
+ if (k === "set-cookie") {
224
+ const cookies = __privateGet(this, _res).headers.getSetCookie();
225
+ _res2.headers.delete("set-cookie");
226
+ for (const cookie of cookies) {
227
+ _res2.headers.append("set-cookie", cookie);
228
+ }
229
+ } else {
230
+ _res2.headers.set(k, v);
231
+ }
232
+ }
225
233
  }
226
234
  __privateSet(this, _res, _res2);
227
235
  this.finalized = true;
@@ -1,5 +1,6 @@
1
1
  // src/router/linear-router/router.ts
2
2
  import { METHOD_NAME_ALL, UnsupportedPathError } from "../../router.js";
3
+ import { checkOptionalParameter } from "../../utils/url.js";
3
4
  var emptyParams = {};
4
5
  var splitPathRe = /\/(:\w+(?:{[^}]+})?)|\/[^\/\?]+|(\?)/g;
5
6
  var splitByStarRe = /\*/;
@@ -9,12 +10,10 @@ var LinearRouter = class {
9
10
  this.routes = [];
10
11
  }
11
12
  add(method, path, handler) {
12
- if (path.charCodeAt(path.length - 1) === 63) {
13
- this.routes.push([method, path.slice(0, -1), handler]);
14
- this.routes.push([method, path.replace(/\/[^/]+$/, ""), handler]);
15
- } else {
16
- this.routes.push([method, path, handler]);
17
- }
13
+ ;
14
+ (checkOptionalParameter(path) || [path]).forEach((p) => {
15
+ this.routes.push([method, p, handler]);
16
+ });
18
17
  }
19
18
  match(method, path) {
20
19
  const handlers = [];
@@ -150,10 +150,7 @@ var RegExpRouter = class {
150
150
  (_a2 = routes[m])[path2] || (_a2[path2] = [
151
151
  ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
152
152
  ]);
153
- routes[m][path2].push([
154
- handler,
155
- paths.length === 2 && i === 0 ? paramCount - 1 : paramCount
156
- ]);
153
+ routes[m][path2].push([handler, paramCount - len + i + 1]);
157
154
  }
158
155
  });
159
156
  }
@@ -1,2 +1,2 @@
1
1
  export { hc } from './client';
2
- export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions } from './types';
2
+ export type { InferResponseType, InferRequestType, Fetch, ClientRequestOptions, ClientRequest, ClientResponse, } from './types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.2",
3
+ "version": "3.12.3",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",