hono 3.7.0 → 3.7.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.
- package/dist/cjs/helper.js +1 -0
- package/dist/cjs/utils/buffer.js +5 -23
- package/dist/cjs/validator/validator.js +1 -1
- package/dist/helper.js +1 -0
- package/dist/types/helper.d.ts +1 -0
- package/dist/types/utils/buffer.d.ts +1 -1
- package/dist/utils/buffer.js +5 -23
- package/dist/validator/validator.js +1 -1
- package/package.json +1 -1
package/dist/cjs/helper.js
CHANGED
|
@@ -18,3 +18,4 @@ module.exports = __toCommonJS(helper_exports);
|
|
|
18
18
|
__reExport(helper_exports, require("./helper/cookie"), module.exports);
|
|
19
19
|
__reExport(helper_exports, require("./helper/html"), module.exports);
|
|
20
20
|
__reExport(helper_exports, require("./helper/adapter"), module.exports);
|
|
21
|
+
__reExport(helper_exports, require("./helper/testing"), module.exports);
|
package/dist/cjs/utils/buffer.js
CHANGED
|
@@ -60,31 +60,13 @@ const bufferToString = (buffer) => {
|
|
|
60
60
|
}
|
|
61
61
|
return buffer;
|
|
62
62
|
};
|
|
63
|
-
const _decodeURIComponent = (str) => decodeURIComponent(str.replace(/\+/g, " "));
|
|
64
63
|
const bufferToFormData = (arrayBuffer, contentType) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const boundaryMatch = contentType.match(/boundary=(.+)/);
|
|
69
|
-
const boundary = boundaryMatch ? boundaryMatch[1] : "";
|
|
70
|
-
if (contentType.startsWith("multipart/form-data") && boundary) {
|
|
71
|
-
const parts = content.split("--" + boundary).slice(1, -1);
|
|
72
|
-
for (const part of parts) {
|
|
73
|
-
const [header, body] = part.split("\r\n\r\n");
|
|
74
|
-
const nameMatch = header.match(/name="([^"]+)"/);
|
|
75
|
-
if (nameMatch) {
|
|
76
|
-
const name = nameMatch[1];
|
|
77
|
-
formData.append(name, body.trim());
|
|
78
|
-
}
|
|
64
|
+
const response = new Response(arrayBuffer, {
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": contentType
|
|
79
67
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
for (const pair of pairs) {
|
|
83
|
-
const [key, value] = pair.split("=");
|
|
84
|
-
formData.append(_decodeURIComponent(key), _decodeURIComponent(value));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return formData;
|
|
68
|
+
});
|
|
69
|
+
return response.formData();
|
|
88
70
|
};
|
|
89
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
90
72
|
0 && (module.exports = {
|
|
@@ -48,7 +48,7 @@ const validator = (target, validationFunc) => {
|
|
|
48
48
|
const contentType = c.req.header("Content-Type");
|
|
49
49
|
if (contentType) {
|
|
50
50
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
51
|
-
const formData = (0, import_buffer.bufferToFormData)(arrayBuffer, contentType);
|
|
51
|
+
const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType);
|
|
52
52
|
const form = {};
|
|
53
53
|
formData.forEach((value2, key) => {
|
|
54
54
|
form[key] = value2;
|
package/dist/helper.js
CHANGED
package/dist/types/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const equal: (a: ArrayBuffer, b: ArrayBuffer) => boolean;
|
|
2
2
|
export declare const timingSafeEqual: (a: string | object | boolean, b: string | object | boolean, hashFunction?: Function) => Promise<boolean>;
|
|
3
3
|
export declare const bufferToString: (buffer: ArrayBuffer) => string;
|
|
4
|
-
export declare const bufferToFormData: (arrayBuffer: ArrayBuffer, contentType: string) => FormData
|
|
4
|
+
export declare const bufferToFormData: (arrayBuffer: ArrayBuffer, contentType: string) => Promise<FormData>;
|
package/dist/utils/buffer.js
CHANGED
|
@@ -35,31 +35,13 @@ var bufferToString = (buffer) => {
|
|
|
35
35
|
}
|
|
36
36
|
return buffer;
|
|
37
37
|
};
|
|
38
|
-
var _decodeURIComponent = (str) => decodeURIComponent(str.replace(/\+/g, " "));
|
|
39
38
|
var bufferToFormData = (arrayBuffer, contentType) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const boundaryMatch = contentType.match(/boundary=(.+)/);
|
|
44
|
-
const boundary = boundaryMatch ? boundaryMatch[1] : "";
|
|
45
|
-
if (contentType.startsWith("multipart/form-data") && boundary) {
|
|
46
|
-
const parts = content.split("--" + boundary).slice(1, -1);
|
|
47
|
-
for (const part of parts) {
|
|
48
|
-
const [header, body] = part.split("\r\n\r\n");
|
|
49
|
-
const nameMatch = header.match(/name="([^"]+)"/);
|
|
50
|
-
if (nameMatch) {
|
|
51
|
-
const name = nameMatch[1];
|
|
52
|
-
formData.append(name, body.trim());
|
|
53
|
-
}
|
|
39
|
+
const response = new Response(arrayBuffer, {
|
|
40
|
+
headers: {
|
|
41
|
+
"Content-Type": contentType
|
|
54
42
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
for (const pair of pairs) {
|
|
58
|
-
const [key, value] = pair.split("=");
|
|
59
|
-
formData.append(_decodeURIComponent(key), _decodeURIComponent(value));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return formData;
|
|
43
|
+
});
|
|
44
|
+
return response.formData();
|
|
63
45
|
};
|
|
64
46
|
export {
|
|
65
47
|
bufferToFormData,
|
|
@@ -26,7 +26,7 @@ var validator = (target, validationFunc) => {
|
|
|
26
26
|
const contentType = c.req.header("Content-Type");
|
|
27
27
|
if (contentType) {
|
|
28
28
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
29
|
-
const formData = bufferToFormData(arrayBuffer, contentType);
|
|
29
|
+
const formData = await bufferToFormData(arrayBuffer, contentType);
|
|
30
30
|
const form = {};
|
|
31
31
|
formData.forEach((value2, key) => {
|
|
32
32
|
form[key] = value2;
|