hono 4.9.5 → 4.9.7

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.
@@ -25,7 +25,7 @@ module.exports = __toCommonJS(fetch_result_please_exports);
25
25
  const nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]);
26
26
  async function fetchRP(fetchRes) {
27
27
  const _fetchRes = await fetchRes;
28
- const hasBody = _fetchRes.body && !nullBodyResponses.has(_fetchRes.status);
28
+ const hasBody = (_fetchRes.body || _fetchRes._bodyInit) && !nullBodyResponses.has(_fetchRes.status);
29
29
  if (hasBody) {
30
30
  const responseType = detectResponseType(_fetchRes);
31
31
  _fetchRes._data = await _fetchRes[responseType]();
@@ -41,7 +41,11 @@ const bodyLimit = (options) => {
41
41
  if (!c.req.raw.body) {
42
42
  return next();
43
43
  }
44
- if (c.req.raw.headers.has("content-length")) {
44
+ const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
45
+ const hasContentLength = c.req.raw.headers.has("content-length");
46
+ if (hasTransferEncoding && hasContentLength) {
47
+ }
48
+ if (hasContentLength && !hasTransferEncoding) {
45
49
  const contentLength = parseInt(c.req.raw.headers.get("content-length") || "0", 10);
46
50
  return contentLength > maxSize ? onError(c) : next();
47
51
  }
@@ -100,10 +100,7 @@ const tryDecode = (str, decoder) => {
100
100
  const tryDecodeURI = (str) => tryDecode(str, decodeURI);
101
101
  const getPath = (request) => {
102
102
  const url = request.url;
103
- const start = url.indexOf(
104
- "/",
105
- url.charCodeAt(9) === 58 ? 13 : 8
106
- );
103
+ const start = url.indexOf("/", url.indexOf(":") + 4);
107
104
  let i = start;
108
105
  for (; i < url.length; i++) {
109
106
  const charCode = url.charCodeAt(i);
@@ -2,7 +2,7 @@
2
2
  var nullBodyResponses = /* @__PURE__ */ new Set([101, 204, 205, 304]);
3
3
  async function fetchRP(fetchRes) {
4
4
  const _fetchRes = await fetchRes;
5
- const hasBody = _fetchRes.body && !nullBodyResponses.has(_fetchRes.status);
5
+ const hasBody = (_fetchRes.body || _fetchRes._bodyInit) && !nullBodyResponses.has(_fetchRes.status);
6
6
  if (hasBody) {
7
7
  const responseType = detectResponseType(_fetchRes);
8
8
  _fetchRes._data = await _fetchRes[responseType]();
@@ -19,7 +19,11 @@ var bodyLimit = (options) => {
19
19
  if (!c.req.raw.body) {
20
20
  return next();
21
21
  }
22
- if (c.req.raw.headers.has("content-length")) {
22
+ const hasTransferEncoding = c.req.raw.headers.has("transfer-encoding");
23
+ const hasContentLength = c.req.raw.headers.has("content-length");
24
+ if (hasTransferEncoding && hasContentLength) {
25
+ }
26
+ if (hasContentLength && !hasTransferEncoding) {
23
27
  const contentLength = parseInt(c.req.raw.headers.get("content-length") || "0", 10);
24
28
  return contentLength > maxSize ? onError(c) : next();
25
29
  }
package/dist/utils/url.js CHANGED
@@ -67,10 +67,7 @@ var tryDecode = (str, decoder) => {
67
67
  var tryDecodeURI = (str) => tryDecode(str, decodeURI);
68
68
  var getPath = (request) => {
69
69
  const url = request.url;
70
- const start = url.indexOf(
71
- "/",
72
- url.charCodeAt(9) === 58 ? 13 : 8
73
- );
70
+ const start = url.indexOf("/", url.indexOf(":") + 4);
74
71
  let i = start;
75
72
  for (; i < url.length; i++) {
76
73
  const charCode = url.charCodeAt(i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.9.5",
3
+ "version": "4.9.7",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",