hono 4.12.32 → 4.12.34
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/helper/proxy/index.js +4 -0
- package/dist/cjs/jsx/base.js +1 -9
- package/dist/cjs/jsx/hooks/index.js +14 -11
- package/dist/cjs/middleware/cors/index.js +1 -1
- package/dist/cjs/middleware/language/language.js +10 -6
- package/dist/cjs/utils/cookie.js +2 -1
- package/dist/helper/proxy/index.js +4 -0
- package/dist/jsx/base.js +1 -9
- package/dist/jsx/hooks/index.js +14 -11
- package/dist/middleware/cors/index.js +1 -1
- package/dist/middleware/language/language.js +10 -6
- package/dist/utils/cookie.js +2 -1
- package/package.json +2 -3
|
@@ -92,6 +92,10 @@ const proxy = async (input, proxyInit) => {
|
|
|
92
92
|
req.headers.delete("accept-encoding");
|
|
93
93
|
const res = await (customFetch || fetch)(req);
|
|
94
94
|
const resHeaders = new Headers(res.headers);
|
|
95
|
+
const connectionValue = resHeaders.get("connection");
|
|
96
|
+
if (connectionValue) {
|
|
97
|
+
connectionValue.split(",").map((h) => h.trim()).filter((h) => ALLOWED_TOKEN_PATTERN.test(h)).forEach((h) => resHeaders.delete(h));
|
|
98
|
+
}
|
|
95
99
|
hopByHopHeaders.forEach((header) => {
|
|
96
100
|
resHeaders.delete(header);
|
|
97
101
|
});
|
package/dist/cjs/jsx/base.js
CHANGED
|
@@ -315,15 +315,7 @@ const shallowEqual = (a, b) => {
|
|
|
315
315
|
return true;
|
|
316
316
|
};
|
|
317
317
|
const memo = (component, propsAreEqual = shallowEqual) => {
|
|
318
|
-
|
|
319
|
-
let prevProps = void 0;
|
|
320
|
-
const wrapper = ((props) => {
|
|
321
|
-
if (prevProps && !propsAreEqual(prevProps, props)) {
|
|
322
|
-
computed = null;
|
|
323
|
-
}
|
|
324
|
-
prevProps = props;
|
|
325
|
-
return computed ||= component(props);
|
|
326
|
-
});
|
|
318
|
+
const wrapper = ((props) => component(props));
|
|
327
319
|
wrapper[import_constants.DOM_MEMO] = propsAreEqual;
|
|
328
320
|
wrapper[import_constants.DOM_RENDERER] = component;
|
|
329
321
|
return wrapper;
|
|
@@ -330,19 +330,22 @@ const useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
|
|
|
330
330
|
}
|
|
331
331
|
return getServerSnapshot();
|
|
332
332
|
}
|
|
333
|
-
const
|
|
334
|
-
const [
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
const snapshot = buildData[0][4] && getServerSnapshot ? getServerSnapshot() : getSnapshot();
|
|
334
|
+
const [, setVersion] = useState(0);
|
|
335
|
+
const latestSnapshot = useRef([snapshot, getSnapshot]);
|
|
336
|
+
latestSnapshot.current = [snapshot, getSnapshot];
|
|
337
|
+
const unsubscribeRef = useRef(null);
|
|
337
338
|
useEffect(() => {
|
|
338
|
-
|
|
339
|
-
|
|
339
|
+
const update2 = () => setVersion((version) => version + 1);
|
|
340
|
+
unsubscribeRef.current?.();
|
|
341
|
+
unsubscribeRef.current = subscribe(update2);
|
|
342
|
+
const [snapshot2, getSnapshot2] = latestSnapshot.current;
|
|
343
|
+
if (!Object.is(snapshot2, getSnapshot2())) {
|
|
344
|
+
update2();
|
|
340
345
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}, []);
|
|
345
|
-
return state;
|
|
346
|
+
}, [subscribe]);
|
|
347
|
+
useEffect(() => () => unsubscribeRef.current?.(), []);
|
|
348
|
+
return snapshot;
|
|
346
349
|
};
|
|
347
350
|
// Annotate the CommonJS export names for ESM import in node:
|
|
348
351
|
0 && (module.exports = {
|
|
@@ -79,7 +79,7 @@ const cors = (options) => {
|
|
|
79
79
|
if (!headers?.length) {
|
|
80
80
|
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
81
81
|
if (requestHeaders) {
|
|
82
|
-
headers = requestHeaders.split(
|
|
82
|
+
headers = requestHeaders.split(",").map((h) => h.trim());
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
if (headers?.length) {
|
|
@@ -69,14 +69,18 @@ const normalizeLanguage = (lang, options) => {
|
|
|
69
69
|
if (exactIndex !== -1) {
|
|
70
70
|
return options.supportedLanguages[exactIndex];
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
72
|
+
let longestMatchIndex = -1;
|
|
73
|
+
let longestMatchLength = -1;
|
|
74
|
+
for (let i = 0; i < compSupported.length; i++) {
|
|
75
|
+
const candidate = compSupported[i];
|
|
76
|
+
if (candidate.length < compLang.length && candidate.length > longestMatchLength && compLang.startsWith(candidate) && compLang[candidate.length] === "-") {
|
|
77
|
+
longestMatchIndex = i;
|
|
78
|
+
longestMatchLength = candidate.length;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
if (longestMatchIndex !== -1) {
|
|
82
|
+
return options.supportedLanguages[longestMatchIndex];
|
|
83
|
+
}
|
|
80
84
|
return void 0;
|
|
81
85
|
} catch {
|
|
82
86
|
return void 0;
|
package/dist/cjs/utils/cookie.js
CHANGED
|
@@ -47,6 +47,7 @@ const verifySignature = async (base64Signature, value, secret) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
50
|
+
const relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
|
|
50
51
|
const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
51
52
|
const trimCookieWhitespace = (value) => {
|
|
52
53
|
let start = 0;
|
|
@@ -79,7 +80,7 @@ const parse = (cookie, name) => {
|
|
|
79
80
|
continue;
|
|
80
81
|
}
|
|
81
82
|
const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
|
|
82
|
-
if (name && name !== cookieName || !
|
|
83
|
+
if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
|
|
83
84
|
continue;
|
|
84
85
|
}
|
|
85
86
|
let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
|
|
@@ -71,6 +71,10 @@ var proxy = async (input, proxyInit) => {
|
|
|
71
71
|
req.headers.delete("accept-encoding");
|
|
72
72
|
const res = await (customFetch || fetch)(req);
|
|
73
73
|
const resHeaders = new Headers(res.headers);
|
|
74
|
+
const connectionValue = resHeaders.get("connection");
|
|
75
|
+
if (connectionValue) {
|
|
76
|
+
connectionValue.split(",").map((h) => h.trim()).filter((h) => ALLOWED_TOKEN_PATTERN.test(h)).forEach((h) => resHeaders.delete(h));
|
|
77
|
+
}
|
|
74
78
|
hopByHopHeaders.forEach((header) => {
|
|
75
79
|
resHeaders.delete(header);
|
|
76
80
|
});
|
package/dist/jsx/base.js
CHANGED
|
@@ -284,15 +284,7 @@ var shallowEqual = (a, b) => {
|
|
|
284
284
|
return true;
|
|
285
285
|
};
|
|
286
286
|
var memo = (component, propsAreEqual = shallowEqual) => {
|
|
287
|
-
|
|
288
|
-
let prevProps = void 0;
|
|
289
|
-
const wrapper = ((props) => {
|
|
290
|
-
if (prevProps && !propsAreEqual(prevProps, props)) {
|
|
291
|
-
computed = null;
|
|
292
|
-
}
|
|
293
|
-
prevProps = props;
|
|
294
|
-
return computed ||= component(props);
|
|
295
|
-
});
|
|
287
|
+
const wrapper = ((props) => component(props));
|
|
296
288
|
wrapper[DOM_MEMO] = propsAreEqual;
|
|
297
289
|
wrapper[DOM_RENDERER] = component;
|
|
298
290
|
return wrapper;
|
package/dist/jsx/hooks/index.js
CHANGED
|
@@ -289,19 +289,22 @@ var useSyncExternalStore = (subscribe, getSnapshot, getServerSnapshot) => {
|
|
|
289
289
|
}
|
|
290
290
|
return getServerSnapshot();
|
|
291
291
|
}
|
|
292
|
-
const
|
|
293
|
-
const [
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
const snapshot = buildData[0][4] && getServerSnapshot ? getServerSnapshot() : getSnapshot();
|
|
293
|
+
const [, setVersion] = useState(0);
|
|
294
|
+
const latestSnapshot = useRef([snapshot, getSnapshot]);
|
|
295
|
+
latestSnapshot.current = [snapshot, getSnapshot];
|
|
296
|
+
const unsubscribeRef = useRef(null);
|
|
296
297
|
useEffect(() => {
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
const update2 = () => setVersion((version) => version + 1);
|
|
299
|
+
unsubscribeRef.current?.();
|
|
300
|
+
unsubscribeRef.current = subscribe(update2);
|
|
301
|
+
const [snapshot2, getSnapshot2] = latestSnapshot.current;
|
|
302
|
+
if (!Object.is(snapshot2, getSnapshot2())) {
|
|
303
|
+
update2();
|
|
299
304
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}, []);
|
|
304
|
-
return state;
|
|
305
|
+
}, [subscribe]);
|
|
306
|
+
useEffect(() => () => unsubscribeRef.current?.(), []);
|
|
307
|
+
return snapshot;
|
|
305
308
|
};
|
|
306
309
|
export {
|
|
307
310
|
STASH_EFFECT,
|
|
@@ -58,7 +58,7 @@ var cors = (options) => {
|
|
|
58
58
|
if (!headers?.length) {
|
|
59
59
|
const requestHeaders = c.req.header("Access-Control-Request-Headers");
|
|
60
60
|
if (requestHeaders) {
|
|
61
|
-
headers = requestHeaders.split(
|
|
61
|
+
headers = requestHeaders.split(",").map((h) => h.trim());
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
if (headers?.length) {
|
|
@@ -39,14 +39,18 @@ var normalizeLanguage = (lang, options) => {
|
|
|
39
39
|
if (exactIndex !== -1) {
|
|
40
40
|
return options.supportedLanguages[exactIndex];
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
42
|
+
let longestMatchIndex = -1;
|
|
43
|
+
let longestMatchLength = -1;
|
|
44
|
+
for (let i = 0; i < compSupported.length; i++) {
|
|
45
|
+
const candidate = compSupported[i];
|
|
46
|
+
if (candidate.length < compLang.length && candidate.length > longestMatchLength && compLang.startsWith(candidate) && compLang[candidate.length] === "-") {
|
|
47
|
+
longestMatchIndex = i;
|
|
48
|
+
longestMatchLength = candidate.length;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
if (longestMatchIndex !== -1) {
|
|
52
|
+
return options.supportedLanguages[longestMatchIndex];
|
|
53
|
+
}
|
|
50
54
|
return void 0;
|
|
51
55
|
} catch {
|
|
52
56
|
return void 0;
|
package/dist/utils/cookie.js
CHANGED
|
@@ -23,6 +23,7 @@ var verifySignature = async (base64Signature, value, secret) => {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
|
|
26
|
+
var relaxedCookieNameRegEx = /^[!#-:<>-[\]-~]+$/;
|
|
26
27
|
var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
|
|
27
28
|
var trimCookieWhitespace = (value) => {
|
|
28
29
|
let start = 0;
|
|
@@ -55,7 +56,7 @@ var parse = (cookie, name) => {
|
|
|
55
56
|
continue;
|
|
56
57
|
}
|
|
57
58
|
const cookieName = trimCookieWhitespace(pairStr.substring(0, valueStartPos));
|
|
58
|
-
if (name && name !== cookieName || !
|
|
59
|
+
if (name && name !== cookieName || !relaxedCookieNameRegEx.test(cookieName) || cookieName in parsedCookie) {
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
61
62
|
let cookieValue = trimCookieWhitespace(pairStr.substring(valueStartPos + 1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.34",
|
|
4
4
|
"description": "Web framework built on Web Standards",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -667,7 +667,7 @@
|
|
|
667
667
|
],
|
|
668
668
|
"devDependencies": {
|
|
669
669
|
"@hono/eslint-config": "^2.1.1",
|
|
670
|
-
"@hono/node-server": "^2.0.
|
|
670
|
+
"@hono/node-server": "^2.0.12",
|
|
671
671
|
"@types/jsdom": "^21.1.7",
|
|
672
672
|
"@types/node": "^24.3.0",
|
|
673
673
|
"@types/ws": "^8.18.1",
|
|
@@ -685,7 +685,6 @@
|
|
|
685
685
|
"prettier": "3.7.4",
|
|
686
686
|
"publint": "0.3.15",
|
|
687
687
|
"typescript": "^6.0.3",
|
|
688
|
-
"undici": "^6.27.0",
|
|
689
688
|
"vite-plugin-fastly-js-compute": "^0.4.2",
|
|
690
689
|
"vitest": "^4.1.9",
|
|
691
690
|
"wrangler": "4.107.0",
|