hono 4.13.0 → 4.13.2

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.
@@ -74,7 +74,7 @@ class ClientRequestImpl {
74
74
  }
75
75
  this.rBody = form;
76
76
  }
77
- if (args.json) {
77
+ if (args.json !== void 0) {
78
78
  this.rBody = JSON.stringify(args.json);
79
79
  this.cType = "application/json";
80
80
  }
@@ -90,9 +90,9 @@ class ClientRequestImpl {
90
90
  if (args?.cookie) {
91
91
  const cookies = [];
92
92
  for (const [key, value] of Object.entries(args.cookie)) {
93
- cookies.push((0, import_cookie.serialize)(key, value, { path: "/" }));
93
+ cookies.push((0, import_cookie.serialize)(key, value));
94
94
  }
95
- headerValues["Cookie"] = cookies.join(",");
95
+ headerValues["Cookie"] = cookies.join("; ");
96
96
  }
97
97
  if (this.cType) {
98
98
  headerValues["Content-Type"] = this.cType;
@@ -101,7 +101,7 @@ const documentMetadataTag = (tag, children, props, sort) => {
101
101
  const string = new import_base.JSXNode(tag, restProps, (0, import_children.toArray)(children || [])).toString();
102
102
  if (string instanceof Promise) {
103
103
  return string.then(
104
- (resString) => (0, import_html.raw)(string, [
104
+ (resString) => (0, import_html.raw)(resString, [
105
105
  ...resString.callbacks || [],
106
106
  insertIntoHead(tag, resString, restProps, precedence)
107
107
  ])
@@ -28,6 +28,8 @@ const cors = (options) => {
28
28
  exposeHeaders: [],
29
29
  ...options
30
30
  };
31
+ const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
32
+ const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
31
33
  const findAllowOrigin = ((optsOrigin) => {
32
34
  if (typeof optsOrigin === "string") {
33
35
  if (optsOrigin === "*") {
@@ -43,11 +45,12 @@ const cors = (options) => {
43
45
  })(opts.origin);
44
46
  const findAllowMethods = ((optsAllowMethods) => {
45
47
  if (typeof optsAllowMethods === "function") {
46
- return optsAllowMethods;
48
+ return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
47
49
  } else if (Array.isArray(optsAllowMethods)) {
48
- return () => optsAllowMethods;
50
+ const methodsStr = optsAllowMethods.join(",");
51
+ return () => methodsStr;
49
52
  } else {
50
- return () => [];
53
+ return () => "";
51
54
  }
52
55
  })(opts.allowMethods);
53
56
  return async function cors2(c, next) {
@@ -61,8 +64,8 @@ const cors = (options) => {
61
64
  if (opts.credentials) {
62
65
  set("Access-Control-Allow-Credentials", "true");
63
66
  }
64
- if (opts.exposeHeaders?.length) {
65
- set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
67
+ if (exposeHeadersStr) {
68
+ set("Access-Control-Expose-Headers", exposeHeadersStr);
66
69
  }
67
70
  if (c.req.method === "OPTIONS") {
68
71
  if (opts.origin !== "*") {
@@ -72,18 +75,18 @@ const cors = (options) => {
72
75
  set("Access-Control-Max-Age", opts.maxAge.toString());
73
76
  }
74
77
  const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
75
- if (allowMethods.length) {
76
- set("Access-Control-Allow-Methods", allowMethods.join(","));
78
+ if (allowMethods) {
79
+ set("Access-Control-Allow-Methods", allowMethods);
77
80
  }
78
- let headers = opts.allowHeaders;
79
- if (!headers?.length) {
81
+ let headersStr = allowHeadersStr;
82
+ if (!headersStr) {
80
83
  const requestHeaders = c.req.header("Access-Control-Request-Headers");
81
84
  if (requestHeaders) {
82
- headers = requestHeaders.split(",").map((h) => h.trim());
85
+ headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
83
86
  }
84
87
  }
85
- if (headers?.length) {
86
- set("Access-Control-Allow-Headers", headers.join(","));
88
+ if (headersStr) {
89
+ set("Access-Control-Allow-Headers", headersStr);
87
90
  c.res.headers.append("Vary", "Access-Control-Request-Headers");
88
91
  }
89
92
  c.res.headers.delete("Content-Length");
@@ -31,18 +31,64 @@ const mergeBuffers = (buffer1, buffer2) => {
31
31
  merged.set(buffer2, buffer1.byteLength);
32
32
  return merged;
33
33
  };
34
+ const CHUNK_SIZE = 256 * 1024;
34
35
  const generateDigest = async (stream, generator) => {
35
36
  if (!stream) {
36
37
  return null;
37
38
  }
38
39
  let result = void 0;
40
+ let chunk;
41
+ let chunkLength = 0;
42
+ const digest = async (body) => {
43
+ result = await generator(mergeBuffers(result, body));
44
+ };
39
45
  const reader = stream.getReader();
40
46
  for (; ; ) {
41
47
  const { value, done } = await reader.read();
42
48
  if (done) {
43
49
  break;
44
50
  }
45
- result = await generator(mergeBuffers(result, value));
51
+ let offset = 0;
52
+ while (offset < value.byteLength) {
53
+ const remaining = value.byteLength - offset;
54
+ if (chunkLength === 0 && remaining >= CHUNK_SIZE) {
55
+ await digest(value.subarray(offset, offset + CHUNK_SIZE));
56
+ offset += CHUNK_SIZE;
57
+ continue;
58
+ }
59
+ const requiredLength = chunkLength + remaining;
60
+ if (requiredLength < CHUNK_SIZE) {
61
+ if (!chunk) {
62
+ chunk = value.subarray(offset);
63
+ } else {
64
+ if (chunk.byteLength < requiredLength) {
65
+ const nextChunk = new Uint8Array(
66
+ new ArrayBuffer(Math.min(CHUNK_SIZE, Math.max(requiredLength, chunk.byteLength * 2)))
67
+ );
68
+ nextChunk.set(chunk.subarray(0, chunkLength));
69
+ chunk = nextChunk;
70
+ }
71
+ chunk.set(value.subarray(offset), chunkLength);
72
+ }
73
+ chunkLength = requiredLength;
74
+ break;
75
+ }
76
+ const length = CHUNK_SIZE - chunkLength;
77
+ if (chunk?.byteLength !== CHUNK_SIZE) {
78
+ const nextChunk = new Uint8Array(new ArrayBuffer(CHUNK_SIZE));
79
+ if (chunk) {
80
+ nextChunk.set(chunk.subarray(0, chunkLength));
81
+ }
82
+ chunk = nextChunk;
83
+ }
84
+ chunk.set(value.subarray(offset, offset + length), chunkLength);
85
+ await digest(chunk);
86
+ chunkLength = 0;
87
+ offset += length;
88
+ }
89
+ }
90
+ if (chunk && chunkLength > 0) {
91
+ await digest(chunk.subarray(0, chunkLength));
46
92
  }
47
93
  if (!result) {
48
94
  return null;
@@ -54,6 +54,9 @@ const etag = (options) => {
54
54
  return async function etag2(c, next) {
55
55
  const ifNoneMatch = c.req.header("If-None-Match") ?? null;
56
56
  await next();
57
+ if (!(c.req.method === "GET" || c.req.method === "HEAD" || c.req.method === "QUERY") || !c.res.ok) {
58
+ return;
59
+ }
57
60
  const res = c.res;
58
61
  let etag3 = res.headers.get("ETag");
59
62
  if (!etag3) {
@@ -70,7 +73,7 @@ const etag = (options) => {
70
73
  }
71
74
  etag3 = weak ? `W/"${hash}"` : `"${hash}"`;
72
75
  }
73
- const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD" || c.req.method === "QUERY") && res.ok : etagMatches(etag3, ifNoneMatch);
76
+ const matched = ifNoneMatch === "*" || etagMatches(etag3, ifNoneMatch);
74
77
  if (matched) {
75
78
  c.res = new Response(null, {
76
79
  status: 304,
@@ -159,14 +159,17 @@ function getPermissionsPolicyDirectives(policy) {
159
159
  return Object.entries(policy).map(([directive, value]) => {
160
160
  const kebabDirective = camelToKebab(directive);
161
161
  if (typeof value === "boolean") {
162
- return `${kebabDirective}=${value ? "*" : "none"}`;
162
+ return `${kebabDirective}=${value ? "*" : "()"}`;
163
163
  }
164
164
  if (Array.isArray(value)) {
165
165
  if (value.length === 0) {
166
166
  return `${kebabDirective}=()`;
167
167
  }
168
- if (value.length === 1 && (value[0] === "*" || value[0] === "none")) {
169
- return `${kebabDirective}=${value[0]}`;
168
+ if (value.length === 1 && value[0] === "*") {
169
+ return `${kebabDirective}=*`;
170
+ }
171
+ if (value.length === 1 && value[0] === "none") {
172
+ return `${kebabDirective}=()`;
170
173
  }
171
174
  const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
172
175
  return `${kebabDirective}=(${allowlist.join(" ")})`;
@@ -166,7 +166,7 @@ class Node {
166
166
  }
167
167
  if (hasChildren(child.#children)) {
168
168
  child.#params = params;
169
- const componentCount = m[0].match(/\//)?.length ?? 0;
169
+ const componentCount = m[0].match(/\//g)?.length ?? 0;
170
170
  const targetCurNodes = curNodesQueue[componentCount] ||= [];
171
171
  targetCurNodes.push(child);
172
172
  }
@@ -80,8 +80,11 @@ class StreamingApi {
80
80
  }
81
81
  async pipe(body) {
82
82
  this.writer.releaseLock();
83
- await body.pipeTo(this.writable, { preventClose: true });
84
- this.writer = this.writable.getWriter();
83
+ try {
84
+ await body.pipeTo(this.writable, { preventClose: true, preventAbort: true });
85
+ } finally {
86
+ this.writer = this.writable.getWriter();
87
+ }
85
88
  }
86
89
  onAbort(listener) {
87
90
  this.abortSubscribers.push(listener);
@@ -142,13 +142,13 @@ const checkOptionalParameter = (path) => {
142
142
  if (segment !== "" && !/\:/.test(segment)) {
143
143
  basePath += "/" + segment;
144
144
  } else if (/\:/.test(segment)) {
145
- if (/\?/.test(segment)) {
145
+ if (segment.charCodeAt(segment.length - 1) === 63) {
146
146
  if (results.length === 0 && basePath === "") {
147
147
  results.push("/");
148
148
  } else {
149
149
  results.push(basePath);
150
150
  }
151
- const optionalSegment = segment.replace("?", "");
151
+ const optionalSegment = segment.slice(0, -1);
152
152
  basePath += "/" + optionalSegment;
153
153
  results.push(basePath);
154
154
  } else {
@@ -60,7 +60,7 @@ var ClientRequestImpl = class {
60
60
  }
61
61
  this.rBody = form;
62
62
  }
63
- if (args.json) {
63
+ if (args.json !== void 0) {
64
64
  this.rBody = JSON.stringify(args.json);
65
65
  this.cType = "application/json";
66
66
  }
@@ -76,9 +76,9 @@ var ClientRequestImpl = class {
76
76
  if (args?.cookie) {
77
77
  const cookies = [];
78
78
  for (const [key, value] of Object.entries(args.cookie)) {
79
- cookies.push(serialize(key, value, { path: "/" }));
79
+ cookies.push(serialize(key, value));
80
80
  }
81
- headerValues["Cookie"] = cookies.join(",");
81
+ headerValues["Cookie"] = cookies.join("; ");
82
82
  }
83
83
  if (this.cType) {
84
84
  headerValues["Content-Type"] = this.cType;
@@ -78,7 +78,7 @@ var documentMetadataTag = (tag, children, props, sort) => {
78
78
  const string = new JSXNode(tag, restProps, toArray(children || [])).toString();
79
79
  if (string instanceof Promise) {
80
80
  return string.then(
81
- (resString) => raw(string, [
81
+ (resString) => raw(resString, [
82
82
  ...resString.callbacks || [],
83
83
  insertIntoHead(tag, resString, restProps, precedence)
84
84
  ])
@@ -7,6 +7,8 @@ var cors = (options) => {
7
7
  exposeHeaders: [],
8
8
  ...options
9
9
  };
10
+ const exposeHeadersStr = opts.exposeHeaders?.length ? opts.exposeHeaders.join(",") : void 0;
11
+ const allowHeadersStr = opts.allowHeaders?.length ? opts.allowHeaders.join(",") : void 0;
10
12
  const findAllowOrigin = ((optsOrigin) => {
11
13
  if (typeof optsOrigin === "string") {
12
14
  if (optsOrigin === "*") {
@@ -22,11 +24,12 @@ var cors = (options) => {
22
24
  })(opts.origin);
23
25
  const findAllowMethods = ((optsAllowMethods) => {
24
26
  if (typeof optsAllowMethods === "function") {
25
- return optsAllowMethods;
27
+ return async (origin, c) => (await optsAllowMethods(origin, c)).join(",");
26
28
  } else if (Array.isArray(optsAllowMethods)) {
27
- return () => optsAllowMethods;
29
+ const methodsStr = optsAllowMethods.join(",");
30
+ return () => methodsStr;
28
31
  } else {
29
- return () => [];
32
+ return () => "";
30
33
  }
31
34
  })(opts.allowMethods);
32
35
  return async function cors2(c, next) {
@@ -40,8 +43,8 @@ var cors = (options) => {
40
43
  if (opts.credentials) {
41
44
  set("Access-Control-Allow-Credentials", "true");
42
45
  }
43
- if (opts.exposeHeaders?.length) {
44
- set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
46
+ if (exposeHeadersStr) {
47
+ set("Access-Control-Expose-Headers", exposeHeadersStr);
45
48
  }
46
49
  if (c.req.method === "OPTIONS") {
47
50
  if (opts.origin !== "*") {
@@ -51,18 +54,18 @@ var cors = (options) => {
51
54
  set("Access-Control-Max-Age", opts.maxAge.toString());
52
55
  }
53
56
  const allowMethods = await findAllowMethods(c.req.header("origin") || "", c);
54
- if (allowMethods.length) {
55
- set("Access-Control-Allow-Methods", allowMethods.join(","));
57
+ if (allowMethods) {
58
+ set("Access-Control-Allow-Methods", allowMethods);
56
59
  }
57
- let headers = opts.allowHeaders;
58
- if (!headers?.length) {
60
+ let headersStr = allowHeadersStr;
61
+ if (!headersStr) {
59
62
  const requestHeaders = c.req.header("Access-Control-Request-Headers");
60
63
  if (requestHeaders) {
61
- headers = requestHeaders.split(",").map((h) => h.trim());
64
+ headersStr = requestHeaders.split(",").map((h) => h.trim()).join(",");
62
65
  }
63
66
  }
64
- if (headers?.length) {
65
- set("Access-Control-Allow-Headers", headers.join(","));
67
+ if (headersStr) {
68
+ set("Access-Control-Allow-Headers", headersStr);
66
69
  c.res.headers.append("Vary", "Access-Control-Request-Headers");
67
70
  }
68
71
  c.res.headers.delete("Content-Length");
@@ -10,18 +10,64 @@ var mergeBuffers = (buffer1, buffer2) => {
10
10
  merged.set(buffer2, buffer1.byteLength);
11
11
  return merged;
12
12
  };
13
+ var CHUNK_SIZE = 256 * 1024;
13
14
  var generateDigest = async (stream, generator) => {
14
15
  if (!stream) {
15
16
  return null;
16
17
  }
17
18
  let result = void 0;
19
+ let chunk;
20
+ let chunkLength = 0;
21
+ const digest = async (body) => {
22
+ result = await generator(mergeBuffers(result, body));
23
+ };
18
24
  const reader = stream.getReader();
19
25
  for (; ; ) {
20
26
  const { value, done } = await reader.read();
21
27
  if (done) {
22
28
  break;
23
29
  }
24
- result = await generator(mergeBuffers(result, value));
30
+ let offset = 0;
31
+ while (offset < value.byteLength) {
32
+ const remaining = value.byteLength - offset;
33
+ if (chunkLength === 0 && remaining >= CHUNK_SIZE) {
34
+ await digest(value.subarray(offset, offset + CHUNK_SIZE));
35
+ offset += CHUNK_SIZE;
36
+ continue;
37
+ }
38
+ const requiredLength = chunkLength + remaining;
39
+ if (requiredLength < CHUNK_SIZE) {
40
+ if (!chunk) {
41
+ chunk = value.subarray(offset);
42
+ } else {
43
+ if (chunk.byteLength < requiredLength) {
44
+ const nextChunk = new Uint8Array(
45
+ new ArrayBuffer(Math.min(CHUNK_SIZE, Math.max(requiredLength, chunk.byteLength * 2)))
46
+ );
47
+ nextChunk.set(chunk.subarray(0, chunkLength));
48
+ chunk = nextChunk;
49
+ }
50
+ chunk.set(value.subarray(offset), chunkLength);
51
+ }
52
+ chunkLength = requiredLength;
53
+ break;
54
+ }
55
+ const length = CHUNK_SIZE - chunkLength;
56
+ if (chunk?.byteLength !== CHUNK_SIZE) {
57
+ const nextChunk = new Uint8Array(new ArrayBuffer(CHUNK_SIZE));
58
+ if (chunk) {
59
+ nextChunk.set(chunk.subarray(0, chunkLength));
60
+ }
61
+ chunk = nextChunk;
62
+ }
63
+ chunk.set(value.subarray(offset, offset + length), chunkLength);
64
+ await digest(chunk);
65
+ chunkLength = 0;
66
+ offset += length;
67
+ }
68
+ }
69
+ if (chunk && chunkLength > 0) {
70
+ await digest(chunk.subarray(0, chunkLength));
25
71
  }
26
72
  if (!result) {
27
73
  return null;
@@ -32,6 +32,9 @@ var etag = (options) => {
32
32
  return async function etag2(c, next) {
33
33
  const ifNoneMatch = c.req.header("If-None-Match") ?? null;
34
34
  await next();
35
+ if (!(c.req.method === "GET" || c.req.method === "HEAD" || c.req.method === "QUERY") || !c.res.ok) {
36
+ return;
37
+ }
35
38
  const res = c.res;
36
39
  let etag3 = res.headers.get("ETag");
37
40
  if (!etag3) {
@@ -48,7 +51,7 @@ var etag = (options) => {
48
51
  }
49
52
  etag3 = weak ? `W/"${hash}"` : `"${hash}"`;
50
53
  }
51
- const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD" || c.req.method === "QUERY") && res.ok : etagMatches(etag3, ifNoneMatch);
54
+ const matched = ifNoneMatch === "*" || etagMatches(etag3, ifNoneMatch);
52
55
  if (matched) {
53
56
  c.res = new Response(null, {
54
57
  status: 304,
@@ -137,14 +137,17 @@ function getPermissionsPolicyDirectives(policy) {
137
137
  return Object.entries(policy).map(([directive, value]) => {
138
138
  const kebabDirective = camelToKebab(directive);
139
139
  if (typeof value === "boolean") {
140
- return `${kebabDirective}=${value ? "*" : "none"}`;
140
+ return `${kebabDirective}=${value ? "*" : "()"}`;
141
141
  }
142
142
  if (Array.isArray(value)) {
143
143
  if (value.length === 0) {
144
144
  return `${kebabDirective}=()`;
145
145
  }
146
- if (value.length === 1 && (value[0] === "*" || value[0] === "none")) {
147
- return `${kebabDirective}=${value[0]}`;
146
+ if (value.length === 1 && value[0] === "*") {
147
+ return `${kebabDirective}=*`;
148
+ }
149
+ if (value.length === 1 && value[0] === "none") {
150
+ return `${kebabDirective}=()`;
148
151
  }
149
152
  const allowlist = value.map((item) => ["self", "src"].includes(item) ? item : `"${item}"`);
150
153
  return `${kebabDirective}=(${allowlist.join(" ")})`;
@@ -145,7 +145,7 @@ var Node = class _Node {
145
145
  }
146
146
  if (hasChildren(child.#children)) {
147
147
  child.#params = params;
148
- const componentCount = m[0].match(/\//)?.length ?? 0;
148
+ const componentCount = m[0].match(/\//g)?.length ?? 0;
149
149
  const targetCurNodes = curNodesQueue[componentCount] ||= [];
150
150
  targetCurNodes.push(child);
151
151
  }
@@ -2,13 +2,13 @@ export type PermissionsPolicyDirective = StandardizedFeatures | ProposedFeatures
2
2
  /**
3
3
  * These features have been declared in a published version of the respective specification.
4
4
  */
5
- type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'microphone' | 'midi' | 'navigationOverride' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
5
+ type StandardizedFeatures = 'accelerometer' | 'ambientLightSensor' | 'attributionReporting' | 'autoplay' | 'battery' | 'bluetooth' | 'camera' | 'chUa' | 'chUaArch' | 'chUaBitness' | 'chUaFullVersion' | 'chUaFullVersionList' | 'chUaHighEntropyValues' | 'chUaMobile' | 'chUaModel' | 'chUaPlatform' | 'chUaPlatformVersion' | 'chUaWow64' | 'computePressure' | 'crossOriginIsolated' | 'directSockets' | 'displayCapture' | 'encryptedMedia' | 'executionWhileNotRendered' | 'executionWhileOutOfViewport' | 'fullscreen' | 'geolocation' | 'gyroscope' | 'hid' | 'identityCredentialsGet' | 'idleDetection' | 'keyboardMap' | 'magnetometer' | 'mediasession' | 'microphone' | 'midi' | 'navigationOverride' | 'otpCredentials' | 'payment' | 'pictureInPicture' | 'publickeyCredentialsGet' | 'screenWakeLock' | 'serial' | 'storageAccess' | 'syncXhr' | 'tools' | 'usb' | 'webShare' | 'windowManagement' | 'xrSpatialTracking';
6
6
  /**
7
7
  * These features have been proposed, but the definitions have not yet been integrated into their respective specs.
8
8
  */
9
- type ProposedFeatures = 'clipboardRead' | 'clipboardWrite' | 'gamepad' | 'sharedAutofill' | 'speakerSelection';
9
+ type ProposedFeatures = 'autofill' | 'clipboardRead' | 'clipboardWrite' | 'deferredFetch' | 'gamepad' | 'languageDetector' | 'languageModel' | 'manualText' | 'rewriter' | 'sharedAutofill' | 'speakerSelection' | 'summarizer' | 'translator' | 'writer';
10
10
  /**
11
11
  * These features generally have an explainer only, but may be available for experimentation by web developers.
12
12
  */
13
- type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
13
+ type ExperimentalFeatures = 'allScreensCapture' | 'browsingTopics' | 'capturedSurfaceControl' | 'conversionMeasurement' | 'digitalCredentialsCreate' | 'digitalCredentialsGet' | 'focusWithoutUserActivation' | 'joinAdInterestGroup' | 'localFonts' | 'monetization' | 'runAdAuction' | 'smartCard' | 'syncScript' | 'trustTokenRedemption' | 'unload' | 'verticalScroll';
14
14
  export {};
@@ -59,8 +59,11 @@ var StreamingApi = class {
59
59
  }
60
60
  async pipe(body) {
61
61
  this.writer.releaseLock();
62
- await body.pipeTo(this.writable, { preventClose: true });
63
- this.writer = this.writable.getWriter();
62
+ try {
63
+ await body.pipeTo(this.writable, { preventClose: true, preventAbort: true });
64
+ } finally {
65
+ this.writer = this.writable.getWriter();
66
+ }
64
67
  }
65
68
  onAbort(listener) {
66
69
  this.abortSubscribers.push(listener);
package/dist/utils/url.js CHANGED
@@ -108,13 +108,13 @@ var checkOptionalParameter = (path) => {
108
108
  if (segment !== "" && !/\:/.test(segment)) {
109
109
  basePath += "/" + segment;
110
110
  } else if (/\:/.test(segment)) {
111
- if (/\?/.test(segment)) {
111
+ if (segment.charCodeAt(segment.length - 1) === 63) {
112
112
  if (results.length === 0 && basePath === "") {
113
113
  results.push("/");
114
114
  } else {
115
115
  results.push(basePath);
116
116
  }
117
- const optionalSegment = segment.replace("?", "");
117
+ const optionalSegment = segment.slice(0, -1);
118
118
  basePath += "/" + optionalSegment;
119
119
  results.push(basePath);
120
120
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.13.0",
3
+ "version": "4.13.2",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",