hono 3.10.2 → 3.10.3
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.
|
@@ -53,11 +53,11 @@ const getSignedCookie = async (c, secret, key) => {
|
|
|
53
53
|
return obj;
|
|
54
54
|
};
|
|
55
55
|
const setCookie = (c, name, value, opt) => {
|
|
56
|
-
const cookie = (0, import_cookie.serialize)(name, value, opt);
|
|
56
|
+
const cookie = (0, import_cookie.serialize)(name, value, { path: "/", ...opt });
|
|
57
57
|
c.header("set-cookie", cookie, { append: true });
|
|
58
58
|
};
|
|
59
59
|
const setSignedCookie = async (c, name, value, secret, opt) => {
|
|
60
|
-
const cookie = await (0, import_cookie.serializeSigned)(name, value, secret, opt);
|
|
60
|
+
const cookie = await (0, import_cookie.serializeSigned)(name, value, secret, { path: "/", ...opt });
|
|
61
61
|
c.header("set-cookie", cookie, { append: true });
|
|
62
62
|
};
|
|
63
63
|
const deleteCookie = (c, name, opt) => {
|
package/dist/cjs/jsx/index.js
CHANGED
|
@@ -122,9 +122,9 @@ class JSXNode {
|
|
|
122
122
|
buffer[0] += ` ${key}="`;
|
|
123
123
|
(0, import_html2.escapeToBuffer)(v, buffer);
|
|
124
124
|
buffer[0] += '"';
|
|
125
|
-
} else if (typeof v === "number") {
|
|
126
|
-
buffer[0] += ` ${key}="${v}"`;
|
|
127
125
|
} else if (v === null || v === void 0) {
|
|
126
|
+
} else if (typeof v === "number" || v.isEscaped) {
|
|
127
|
+
buffer[0] += ` ${key}="${v}"`;
|
|
128
128
|
} else if (typeof v === "boolean" && booleanAttributes.includes(key)) {
|
|
129
129
|
if (v) {
|
|
130
130
|
buffer[0] += ` ${key}=""`;
|
|
@@ -26,13 +26,21 @@ var import_buffer = require("../utils/buffer");
|
|
|
26
26
|
const validator = (target, validationFunc) => {
|
|
27
27
|
return async (c, next) => {
|
|
28
28
|
let value = {};
|
|
29
|
+
const contentType = c.req.header("Content-Type");
|
|
29
30
|
switch (target) {
|
|
30
31
|
case "json":
|
|
32
|
+
if (!contentType || !contentType.startsWith("application/json")) {
|
|
33
|
+
const message = `Invalid HTTP header: Content-Type=${contentType}`;
|
|
34
|
+
console.error(message);
|
|
35
|
+
return c.json(
|
|
36
|
+
{
|
|
37
|
+
success: false,
|
|
38
|
+
message
|
|
39
|
+
},
|
|
40
|
+
400
|
|
41
|
+
);
|
|
42
|
+
}
|
|
31
43
|
try {
|
|
32
|
-
const contentType = c.req.header("Content-Type");
|
|
33
|
-
if (!contentType || !contentType.startsWith("application/json")) {
|
|
34
|
-
throw new Error(`Invalid HTTP header: Content-Type=${contentType}`);
|
|
35
|
-
}
|
|
36
44
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
37
45
|
value = await new Response(arrayBuffer).json();
|
|
38
46
|
c.req.bodyCache.json = value;
|
|
@@ -50,10 +58,10 @@ const validator = (target, validationFunc) => {
|
|
|
50
58
|
break;
|
|
51
59
|
case "form": {
|
|
52
60
|
try {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
61
|
+
const contentType2 = c.req.header("Content-Type");
|
|
62
|
+
if (contentType2) {
|
|
55
63
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
56
|
-
const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer,
|
|
64
|
+
const formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType2);
|
|
57
65
|
const form = {};
|
|
58
66
|
formData.forEach((value2, key) => {
|
|
59
67
|
form[key] = value2;
|
|
@@ -27,11 +27,11 @@ var getSignedCookie = async (c, secret, key) => {
|
|
|
27
27
|
return obj;
|
|
28
28
|
};
|
|
29
29
|
var setCookie = (c, name, value, opt) => {
|
|
30
|
-
const cookie = serialize(name, value, opt);
|
|
30
|
+
const cookie = serialize(name, value, { path: "/", ...opt });
|
|
31
31
|
c.header("set-cookie", cookie, { append: true });
|
|
32
32
|
};
|
|
33
33
|
var setSignedCookie = async (c, name, value, secret, opt) => {
|
|
34
|
-
const cookie = await serializeSigned(name, value, secret, opt);
|
|
34
|
+
const cookie = await serializeSigned(name, value, secret, { path: "/", ...opt });
|
|
35
35
|
c.header("set-cookie", cookie, { append: true });
|
|
36
36
|
};
|
|
37
37
|
var deleteCookie = (c, name, opt) => {
|
package/dist/jsx/index.js
CHANGED
|
@@ -95,9 +95,9 @@ var JSXNode = class {
|
|
|
95
95
|
buffer[0] += ` ${key}="`;
|
|
96
96
|
escapeToBuffer(v, buffer);
|
|
97
97
|
buffer[0] += '"';
|
|
98
|
-
} else if (typeof v === "number") {
|
|
99
|
-
buffer[0] += ` ${key}="${v}"`;
|
|
100
98
|
} else if (v === null || v === void 0) {
|
|
99
|
+
} else if (typeof v === "number" || v.isEscaped) {
|
|
100
|
+
buffer[0] += ` ${key}="${v}"`;
|
|
101
101
|
} else if (typeof v === "boolean" && booleanAttributes.includes(key)) {
|
|
102
102
|
if (v) {
|
|
103
103
|
buffer[0] += ` ${key}=""`;
|
|
@@ -4,13 +4,21 @@ import { bufferToFormData } from "../utils/buffer.js";
|
|
|
4
4
|
var validator = (target, validationFunc) => {
|
|
5
5
|
return async (c, next) => {
|
|
6
6
|
let value = {};
|
|
7
|
+
const contentType = c.req.header("Content-Type");
|
|
7
8
|
switch (target) {
|
|
8
9
|
case "json":
|
|
10
|
+
if (!contentType || !contentType.startsWith("application/json")) {
|
|
11
|
+
const message = `Invalid HTTP header: Content-Type=${contentType}`;
|
|
12
|
+
console.error(message);
|
|
13
|
+
return c.json(
|
|
14
|
+
{
|
|
15
|
+
success: false,
|
|
16
|
+
message
|
|
17
|
+
},
|
|
18
|
+
400
|
|
19
|
+
);
|
|
20
|
+
}
|
|
9
21
|
try {
|
|
10
|
-
const contentType = c.req.header("Content-Type");
|
|
11
|
-
if (!contentType || !contentType.startsWith("application/json")) {
|
|
12
|
-
throw new Error(`Invalid HTTP header: Content-Type=${contentType}`);
|
|
13
|
-
}
|
|
14
22
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
15
23
|
value = await new Response(arrayBuffer).json();
|
|
16
24
|
c.req.bodyCache.json = value;
|
|
@@ -28,10 +36,10 @@ var validator = (target, validationFunc) => {
|
|
|
28
36
|
break;
|
|
29
37
|
case "form": {
|
|
30
38
|
try {
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
39
|
+
const contentType2 = c.req.header("Content-Type");
|
|
40
|
+
if (contentType2) {
|
|
33
41
|
const arrayBuffer = c.req.bodyCache.arrayBuffer ?? await c.req.raw.arrayBuffer();
|
|
34
|
-
const formData = await bufferToFormData(arrayBuffer,
|
|
42
|
+
const formData = await bufferToFormData(arrayBuffer, contentType2);
|
|
35
43
|
const form = {};
|
|
36
44
|
formData.forEach((value2, key) => {
|
|
37
45
|
form[key] = value2;
|