hono 4.12.29 → 4.12.30
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.
- package/dist/cjs/client/utils.js +1 -1
- package/dist/cjs/middleware/cache/index.js +1 -1
- package/dist/cjs/middleware/compress/index.js +2 -1
- package/dist/cjs/middleware/method-override/index.js +5 -3
- package/dist/client/utils.js +1 -1
- package/dist/middleware/cache/index.js +1 -1
- package/dist/middleware/compress/index.js +2 -1
- package/dist/middleware/method-override/index.js +5 -3
- package/dist/types/helper/websocket/index.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/client/utils.js
CHANGED
|
@@ -36,7 +36,7 @@ const mergePath = (base, path) => {
|
|
|
36
36
|
};
|
|
37
37
|
const replaceUrlParam = (urlString, params) => {
|
|
38
38
|
for (const [k, v] of Object.entries(params)) {
|
|
39
|
-
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
|
|
39
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
40
40
|
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
41
41
|
}
|
|
42
42
|
return urlString;
|
|
@@ -55,7 +55,7 @@ const cache = (options) => {
|
|
|
55
55
|
);
|
|
56
56
|
const addHeader = (c, responseVary) => {
|
|
57
57
|
if (cacheControlDirectives) {
|
|
58
|
-
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
|
|
58
|
+
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
|
|
59
59
|
for (const directive of cacheControlDirectives) {
|
|
60
60
|
let [name, value] = directive.trim().split("=", 2);
|
|
61
61
|
name = name.toLowerCase();
|
|
@@ -57,7 +57,8 @@ const compress = (options) => {
|
|
|
57
57
|
return async function compress2(ctx, next) {
|
|
58
58
|
await next();
|
|
59
59
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
60
|
-
if (ctx.res.
|
|
60
|
+
if (ctx.res.status === 206 || // partial content, Content-Range refers to the uncompressed bytes
|
|
61
|
+
ctx.res.headers.has("Content-Encoding") || // already encoded
|
|
61
62
|
ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
|
|
62
63
|
ctx.req.method === "HEAD" || // HEAD request
|
|
63
64
|
contentLength && Number(contentLength) < threshold || // content-length below threshold
|
|
@@ -80,11 +80,13 @@ const methodOverride = (options) => async function methodOverride2(c, next) {
|
|
|
80
80
|
if (method) {
|
|
81
81
|
const url = new URL(c.req.url);
|
|
82
82
|
url.searchParams.delete(queryName);
|
|
83
|
-
const
|
|
83
|
+
const requestInit = {
|
|
84
84
|
body: c.req.raw.body,
|
|
85
85
|
headers: c.req.raw.headers,
|
|
86
|
-
method
|
|
87
|
-
|
|
86
|
+
method,
|
|
87
|
+
duplex: c.req.raw.body ? "half" : void 0
|
|
88
|
+
};
|
|
89
|
+
const request = new Request(url.toString(), requestInit);
|
|
88
90
|
return app.fetch(request, c.env, getExecutionCtx(c));
|
|
89
91
|
}
|
|
90
92
|
}
|
package/dist/client/utils.js
CHANGED
|
@@ -8,7 +8,7 @@ var mergePath = (base, path) => {
|
|
|
8
8
|
};
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
|
-
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
|
|
11
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
12
|
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
@@ -34,7 +34,7 @@ var cache = (options) => {
|
|
|
34
34
|
);
|
|
35
35
|
const addHeader = (c, responseVary) => {
|
|
36
36
|
if (cacheControlDirectives) {
|
|
37
|
-
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
|
|
37
|
+
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
|
|
38
38
|
for (const directive of cacheControlDirectives) {
|
|
39
39
|
let [name, value] = directive.trim().split("=", 2);
|
|
40
40
|
name = name.toLowerCase();
|
|
@@ -35,7 +35,8 @@ var compress = (options) => {
|
|
|
35
35
|
return async function compress2(ctx, next) {
|
|
36
36
|
await next();
|
|
37
37
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
38
|
-
if (ctx.res.
|
|
38
|
+
if (ctx.res.status === 206 || // partial content, Content-Range refers to the uncompressed bytes
|
|
39
|
+
ctx.res.headers.has("Content-Encoding") || // already encoded
|
|
39
40
|
ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
|
|
40
41
|
ctx.req.method === "HEAD" || // HEAD request
|
|
41
42
|
contentLength && Number(contentLength) < threshold || // content-length below threshold
|
|
@@ -59,11 +59,13 @@ var methodOverride = (options) => async function methodOverride2(c, next) {
|
|
|
59
59
|
if (method) {
|
|
60
60
|
const url = new URL(c.req.url);
|
|
61
61
|
url.searchParams.delete(queryName);
|
|
62
|
-
const
|
|
62
|
+
const requestInit = {
|
|
63
63
|
body: c.req.raw.body,
|
|
64
64
|
headers: c.req.raw.headers,
|
|
65
|
-
method
|
|
66
|
-
|
|
65
|
+
method,
|
|
66
|
+
duplex: c.req.raw.body ? "half" : void 0
|
|
67
|
+
};
|
|
68
|
+
const request = new Request(url.toString(), requestInit);
|
|
67
69
|
return app.fetch(request, c.env, getExecutionCtx(c));
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -31,7 +31,7 @@ export type WSReadyState = 0 | 1 | 2 | 3;
|
|
|
31
31
|
* An argument for WSContext class
|
|
32
32
|
*/
|
|
33
33
|
export interface WSContextInit<T = unknown> {
|
|
34
|
-
send(data: string | ArrayBuffer | Uint8Array
|
|
34
|
+
send(data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options: SendOptions): void;
|
|
35
35
|
close(code?: number, reason?: string): void;
|
|
36
36
|
raw?: T;
|
|
37
37
|
readyState: WSReadyState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.30",
|
|
4
4
|
"description": "Web framework built on Web Standards",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -666,7 +666,7 @@
|
|
|
666
666
|
"nodejs"
|
|
667
667
|
],
|
|
668
668
|
"devDependencies": {
|
|
669
|
-
"@hono/eslint-config": "^2.1.
|
|
669
|
+
"@hono/eslint-config": "^2.1.1",
|
|
670
670
|
"@hono/node-server": "^2.0.2",
|
|
671
671
|
"@types/jsdom": "^21.1.7",
|
|
672
672
|
"@types/node": "^24.3.0",
|
|
@@ -684,7 +684,7 @@
|
|
|
684
684
|
"pkg-pr-new": "^0.0.53",
|
|
685
685
|
"prettier": "3.7.4",
|
|
686
686
|
"publint": "0.3.15",
|
|
687
|
-
"typescript": "^
|
|
687
|
+
"typescript": "^6.0.3",
|
|
688
688
|
"undici": "^6.27.0",
|
|
689
689
|
"vite-plugin-fastly-js-compute": "^0.4.2",
|
|
690
690
|
"vitest": "^4.1.9",
|