hono 4.13.3 → 4.13.5
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/client.js +25 -11
- package/dist/cjs/client/utils.js +3 -0
- package/dist/cjs/helper/accepts/accepts.js +36 -2
- package/dist/cjs/helper/ssg/ssg.js +1 -1
- package/dist/cjs/helper/ssg/utils.js +30 -10
- package/dist/cjs/jsx/dom/render.js +2 -0
- package/dist/cjs/middleware/cache/index.js +1 -1
- package/dist/cjs/middleware/etag/index.js +1 -1
- package/dist/cjs/request.js +8 -4
- package/dist/cjs/router/reg-exp-router/node.js +10 -3
- package/dist/cjs/router/reg-exp-router/router.js +47 -83
- package/dist/cjs/router/reg-exp-router/trie.js +2 -1
- package/dist/cjs/router/trie-router/node.js +4 -3
- package/dist/cjs/router/utils.js +27 -0
- package/dist/cjs/utils/body.js +15 -3
- package/dist/cjs/utils/cookie.js +1 -1
- package/dist/cjs/utils/stream.js +7 -1
- package/dist/cjs/utils/url.js +9 -1
- package/dist/client/client.js +25 -11
- package/dist/client/utils.js +3 -0
- package/dist/helper/accepts/accepts.js +36 -2
- package/dist/helper/ssg/ssg.js +1 -1
- package/dist/helper/ssg/utils.js +30 -10
- package/dist/jsx/dom/render.js +2 -0
- package/dist/middleware/cache/index.js +1 -1
- package/dist/middleware/etag/index.js +1 -1
- package/dist/request.js +8 -4
- package/dist/router/reg-exp-router/node.js +6 -2
- package/dist/router/reg-exp-router/router.js +53 -84
- package/dist/router/reg-exp-router/trie.js +2 -1
- package/dist/router/trie-router/node.js +4 -3
- package/dist/router/utils.js +5 -0
- package/dist/types/router/reg-exp-router/node.d.ts +3 -0
- package/dist/types/router/utils.d.ts +1 -0
- package/dist/types/utils/url.d.ts +4 -0
- package/dist/utils/body.js +15 -3
- package/dist/utils/cookie.js +1 -1
- package/dist/utils/stream.js +7 -1
- package/dist/utils/url.js +9 -1
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/router/trie-router/node.ts
|
|
2
2
|
import { METHOD_NAME_ALL } from "../../router.js";
|
|
3
3
|
import { getPattern, splitPath, splitRoutingPath } from "../../utils/url.js";
|
|
4
|
-
|
|
4
|
+
import { createNullObject } from "../utils.js";
|
|
5
|
+
var emptyParams = createNullObject();
|
|
5
6
|
var order = 0;
|
|
6
7
|
var Node = class _Node {
|
|
7
8
|
#methods = [];
|
|
8
|
-
#children =
|
|
9
|
+
#children = createNullObject();
|
|
9
10
|
#patterns = [];
|
|
10
11
|
#pattern;
|
|
11
12
|
#params = emptyParams;
|
|
@@ -42,7 +43,7 @@ var Node = class _Node {
|
|
|
42
43
|
const m = node.#methods[i];
|
|
43
44
|
const handlerSet = m[method] || m[METHOD_NAME_ALL];
|
|
44
45
|
if (handlerSet) {
|
|
45
|
-
handlerSet.params =
|
|
46
|
+
handlerSet.params = createNullObject();
|
|
46
47
|
handlerSets.push(handlerSet);
|
|
47
48
|
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
48
49
|
const key = handlerSet.possibleKeys[i2];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export declare const LABEL_REG_EXP_STR = "[^/]+";
|
|
2
|
+
export declare const ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
3
|
+
export declare const TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
1
4
|
export declare const PATH_ERROR: unique symbol;
|
|
2
5
|
export type ParamAssocArray = [string, number][];
|
|
3
6
|
export interface Context {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createNullObject: () => any;
|
|
@@ -19,6 +19,10 @@ export declare const tryDecode: (str: string, decoder: Decoder) => string;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const tryDecodeURI: (str: string) => string;
|
|
21
21
|
export declare const getPath: (request: Request) => string;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated
|
|
24
|
+
* Use the `URL` API instead.
|
|
25
|
+
*/
|
|
22
26
|
export declare const getQueryStrings: (url: string) => string;
|
|
23
27
|
export declare const getPathNoStrict: (request: Request) => string;
|
|
24
28
|
/**
|
package/dist/utils/body.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/utils/body.ts
|
|
2
2
|
import { bufferToFormData } from "./buffer.js";
|
|
3
|
+
var MAX_NESTING_DEPTH = 32;
|
|
4
|
+
var MAX_NESTED_OBJECTS = 1e4;
|
|
3
5
|
var isRawRequest = (request) => "headers" in request;
|
|
4
6
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
5
7
|
const { all = false, dot = false } = options;
|
|
@@ -32,6 +34,7 @@ async function parseFormData(request, options) {
|
|
|
32
34
|
}
|
|
33
35
|
function convertFormDataToBodyData(formData, options) {
|
|
34
36
|
const form = /* @__PURE__ */ Object.create(null);
|
|
37
|
+
const nestingState = { count: 0 };
|
|
35
38
|
formData.forEach((value, key) => {
|
|
36
39
|
const shouldParseAllValues = options.all || key.endsWith("[]");
|
|
37
40
|
if (!shouldParseAllValues) {
|
|
@@ -44,7 +47,7 @@ function convertFormDataToBodyData(formData, options) {
|
|
|
44
47
|
Object.entries(form).forEach(([key, value]) => {
|
|
45
48
|
const shouldParseDotValues = key.includes(".");
|
|
46
49
|
if (shouldParseDotValues) {
|
|
47
|
-
handleParsingNestedValues(form, key, value);
|
|
50
|
+
handleParsingNestedValues(form, key, value, nestingState);
|
|
48
51
|
delete form[key];
|
|
49
52
|
}
|
|
50
53
|
});
|
|
@@ -67,23 +70,32 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
};
|
|
70
|
-
var handleParsingNestedValues = (form, key, value) => {
|
|
73
|
+
var handleParsingNestedValues = (form, key, value, state) => {
|
|
71
74
|
if (/(?:^|\.)__proto__\./.test(key)) {
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
77
|
let nestedForm = form;
|
|
75
|
-
const keys = key.split(".");
|
|
78
|
+
const keys = key.split(".", MAX_NESTING_DEPTH + 2);
|
|
79
|
+
if (keys.length > MAX_NESTING_DEPTH + 1) {
|
|
80
|
+
throwNestingLimitExceeded();
|
|
81
|
+
}
|
|
76
82
|
keys.forEach((key2, index) => {
|
|
77
83
|
if (index === keys.length - 1) {
|
|
78
84
|
nestedForm[key2] = value;
|
|
79
85
|
} else {
|
|
80
86
|
if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
|
|
87
|
+
if (state.count++ >= MAX_NESTED_OBJECTS) {
|
|
88
|
+
throwNestingLimitExceeded();
|
|
89
|
+
}
|
|
81
90
|
nestedForm[key2] = /* @__PURE__ */ Object.create(null);
|
|
82
91
|
}
|
|
83
92
|
nestedForm = nestedForm[key2];
|
|
84
93
|
}
|
|
85
94
|
});
|
|
86
95
|
};
|
|
96
|
+
var throwNestingLimitExceeded = () => {
|
|
97
|
+
throw new Error("Nesting limit exceeded");
|
|
98
|
+
};
|
|
87
99
|
export {
|
|
88
100
|
parseBody
|
|
89
101
|
};
|
package/dist/utils/cookie.js
CHANGED
|
@@ -77,7 +77,7 @@ var parseSigned = async (cookie, secret, name) => {
|
|
|
77
77
|
const secretKey = await getCryptoKey(secret);
|
|
78
78
|
for (const [key, value] of Object.entries(parse(cookie, name))) {
|
|
79
79
|
const signatureStartPos = value.lastIndexOf(".");
|
|
80
|
-
if (signatureStartPos <
|
|
80
|
+
if (signatureStartPos < 0) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
const signedValue = value.substring(0, signatureStartPos);
|
package/dist/utils/stream.js
CHANGED
|
@@ -75,7 +75,13 @@ var StreamingApi = class {
|
|
|
75
75
|
abort() {
|
|
76
76
|
if (!this.aborted) {
|
|
77
77
|
this.aborted = true;
|
|
78
|
-
this.abortSubscribers.forEach((subscriber) =>
|
|
78
|
+
this.abortSubscribers.forEach((subscriber) => {
|
|
79
|
+
try {
|
|
80
|
+
void Promise.resolve(subscriber()).catch(() => {
|
|
81
|
+
});
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
});
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
};
|
package/dist/utils/url.js
CHANGED
|
@@ -85,7 +85,11 @@ var getPath = (request) => {
|
|
|
85
85
|
};
|
|
86
86
|
var getQueryStrings = (url) => {
|
|
87
87
|
const queryIndex = url.indexOf("?", 8);
|
|
88
|
-
|
|
88
|
+
if (queryIndex === -1) {
|
|
89
|
+
return "";
|
|
90
|
+
}
|
|
91
|
+
const hashIndex = url.indexOf("#", 8);
|
|
92
|
+
return hashIndex === -1 ? url.slice(queryIndex) : queryIndex < hashIndex ? url.slice(queryIndex, hashIndex) : "";
|
|
89
93
|
};
|
|
90
94
|
var getPathNoStrict = (request) => {
|
|
91
95
|
const result = getPath(request);
|
|
@@ -132,6 +136,10 @@ var _decodeURI = (value) => {
|
|
|
132
136
|
return tryDecodeURIComponent(value);
|
|
133
137
|
};
|
|
134
138
|
var _getQueryParam = (url, key, multiple) => {
|
|
139
|
+
const hashIndex = url.indexOf("#", 8);
|
|
140
|
+
if (hashIndex !== -1) {
|
|
141
|
+
url = url.slice(0, hashIndex);
|
|
142
|
+
}
|
|
135
143
|
let encoded;
|
|
136
144
|
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
137
145
|
let keyIndex2 = url.indexOf("?", 8);
|