hono 4.7.2 → 4.7.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.
@@ -89,10 +89,9 @@ class Hono {
89
89
  });
90
90
  return this;
91
91
  };
92
- const strict = options.strict ?? true;
93
- delete options.strict;
94
- Object.assign(this, options);
95
- this.getPath = strict ? options.getPath ?? import_url.getPath : import_url.getPathNoStrict;
92
+ const { strict, ...optionsWithoutStrict } = options;
93
+ Object.assign(this, optionsWithoutStrict);
94
+ this.getPath = strict ?? true ? options.getPath ?? import_url.getPath : import_url.getPathNoStrict;
96
95
  }
97
96
  #clone() {
98
97
  const clone = new Hono({
@@ -41,13 +41,15 @@ class PatternRouter {
41
41
  return match ? `/(?<${match[1]}>${match[2] || "[^/]+"})` : part === "/*" ? "/[^/]+" : part.replace(/[.\\+*[^\]$()]/g, "\\$&");
42
42
  }
43
43
  );
44
- let re;
45
44
  try {
46
- re = new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`);
45
+ this.#routes.push([
46
+ new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
47
+ method,
48
+ handler
49
+ ]);
47
50
  } catch {
48
51
  throw new import_router.UnsupportedPathError();
49
52
  }
50
- this.#routes.push([re, method, handler]);
51
53
  }
52
54
  match(method, path) {
53
55
  const handlers = [];
@@ -31,7 +31,7 @@ var import_jwa = require("./jwa");
31
31
  var import_jws = require("./jws");
32
32
  var import_types = require("./types");
33
33
  var import_utf8 = require("./utf8");
34
- const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.utf8Encoder.encode(JSON.stringify(part))).replace(/=/g, "");
34
+ const encodeJwtPart = (part) => (0, import_encode.encodeBase64Url)(import_utf8.utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, "");
35
35
  const encodeSignaturePart = (buf) => (0, import_encode.encodeBase64Url)(buf).replace(/=/g, "");
36
36
  const decodeJwtPart = (part) => JSON.parse(import_utf8.utf8Decoder.decode((0, import_encode.decodeBase64Url)(part)));
37
37
  function isTokenHeader(obj) {
@@ -129,7 +129,7 @@ const mergePath = (base, sub, ...rest) => {
129
129
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
130
130
  };
131
131
  const checkOptionalParameter = (path) => {
132
- if (!path.match(/\:.+\?$/)) {
132
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
133
133
  return null;
134
134
  }
135
135
  const segments = path.split("/");
package/dist/hono-base.js CHANGED
@@ -67,10 +67,9 @@ var Hono = class {
67
67
  });
68
68
  return this;
69
69
  };
70
- const strict = options.strict ?? true;
71
- delete options.strict;
72
- Object.assign(this, options);
73
- this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
70
+ const { strict, ...optionsWithoutStrict } = options;
71
+ Object.assign(this, optionsWithoutStrict);
72
+ this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
74
73
  }
75
74
  #clone() {
76
75
  const clone = new Hono({
@@ -19,13 +19,15 @@ var PatternRouter = class {
19
19
  return match ? `/(?<${match[1]}>${match[2] || "[^/]+"})` : part === "/*" ? "/[^/]+" : part.replace(/[.\\+*[^\]$()]/g, "\\$&");
20
20
  }
21
21
  );
22
- let re;
23
22
  try {
24
- re = new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`);
23
+ this.#routes.push([
24
+ new RegExp(`^${parts.join("")}${endsWithWildcard ? "" : "/?$"}`),
25
+ method,
26
+ handler
27
+ ]);
25
28
  } catch {
26
29
  throw new UnsupportedPathError();
27
30
  }
28
- this.#routes.push([re, method, handler]);
29
31
  }
30
32
  match(method, path) {
31
33
  const handlers = [];
@@ -9,7 +9,7 @@ export interface BunServerWebSocket<T> {
9
9
  data: T;
10
10
  readyState: 0 | 1 | 2 | 3;
11
11
  }
12
- interface BunWebSocketHandler<T> {
12
+ export interface BunWebSocketHandler<T> {
13
13
  open(ws: BunServerWebSocket<T>): void;
14
14
  close(ws: BunServerWebSocket<T>, code?: number, reason?: string): void;
15
15
  message(ws: BunServerWebSocket<T>, message: string | {
@@ -27,7 +27,7 @@ export type WSReadyState = 0 | 1 | 2 | 3;
27
27
  * An argument for WSContext class
28
28
  */
29
29
  export interface WSContextInit<T = unknown> {
30
- send(data: string | ArrayBuffer, options: SendOptions): void;
30
+ send(data: string | ArrayBuffer | Uint8Array, options: SendOptions): void;
31
31
  close(code?: number, reason?: string): void;
32
32
  raw?: T;
33
33
  readyState: WSReadyState;
@@ -12,7 +12,7 @@ import {
12
12
  JwtTokenSignatureMismatched
13
13
  } from "./types.js";
14
14
  import { utf8Decoder, utf8Encoder } from "./utf8.js";
15
- var encodeJwtPart = (part) => encodeBase64Url(utf8Encoder.encode(JSON.stringify(part))).replace(/=/g, "");
15
+ var encodeJwtPart = (part) => encodeBase64Url(utf8Encoder.encode(JSON.stringify(part)).buffer).replace(/=/g, "");
16
16
  var encodeSignaturePart = (buf) => encodeBase64Url(buf).replace(/=/g, "");
17
17
  var decodeJwtPart = (part) => JSON.parse(utf8Decoder.decode(decodeBase64Url(part)));
18
18
  function isTokenHeader(obj) {
package/dist/utils/url.js CHANGED
@@ -96,7 +96,7 @@ var mergePath = (base, sub, ...rest) => {
96
96
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
97
97
  };
98
98
  var checkOptionalParameter = (path) => {
99
- if (!path.match(/\:.+\?$/)) {
99
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
100
100
  return null;
101
101
  }
102
102
  const segments = path.split("/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.7.2",
3
+ "version": "4.7.3",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",