hono 4.5.5 → 4.5.6
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/utils/html.js
CHANGED
|
@@ -41,13 +41,14 @@ const escapeRe = /[&<>'"]/;
|
|
|
41
41
|
const stringBufferToString = async (buffer, callbacks) => {
|
|
42
42
|
let str = "";
|
|
43
43
|
callbacks ||= [];
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const resolvedBuffer = await Promise.all(buffer);
|
|
45
|
+
for (let i = resolvedBuffer.length - 1; ; i--) {
|
|
46
|
+
str += resolvedBuffer[i];
|
|
46
47
|
i--;
|
|
47
48
|
if (i < 0) {
|
|
48
49
|
break;
|
|
49
50
|
}
|
|
50
|
-
let r =
|
|
51
|
+
let r = resolvedBuffer[i];
|
|
51
52
|
if (typeof r === "object") {
|
|
52
53
|
callbacks.push(...r.callbacks || []);
|
|
53
54
|
}
|
|
@@ -25,7 +25,7 @@ var import_cookie = require("../helper/cookie");
|
|
|
25
25
|
var import_http_exception = require("../http-exception");
|
|
26
26
|
var import_buffer = require("../utils/buffer");
|
|
27
27
|
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
28
|
-
const multipartRegex = /^multipart\/form-data(
|
|
28
|
+
const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
|
|
29
29
|
const urlencodedRegex = /^application\/x-www-form-urlencoded$/;
|
|
30
30
|
const validator = (target, validationFunc) => {
|
|
31
31
|
return async (c, next) => {
|
|
@@ -64,12 +64,13 @@ const validator = (target, validationFunc) => {
|
|
|
64
64
|
const form = {};
|
|
65
65
|
formData.forEach((value2, key) => {
|
|
66
66
|
if (key.endsWith("[]")) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
;
|
|
68
|
+
(form[key] ??= []).push(value2);
|
|
69
|
+
} else if (Array.isArray(form[key])) {
|
|
70
|
+
;
|
|
71
|
+
form[key].push(value2);
|
|
72
|
+
} else if (key in form) {
|
|
73
|
+
form[key] = [form[key], value2];
|
|
73
74
|
} else {
|
|
74
75
|
form[key] = value2;
|
|
75
76
|
}
|
|
@@ -381,13 +381,31 @@ export declare namespace JSX {
|
|
|
381
381
|
preload?: string | undefined;
|
|
382
382
|
src?: string | undefined;
|
|
383
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* String literal types with auto-completion
|
|
386
|
+
* @see https://github.com/Microsoft/TypeScript/issues/29729
|
|
387
|
+
*/
|
|
388
|
+
type LiteralUnion<T> = T | (string & Record<never, never>);
|
|
389
|
+
/**
|
|
390
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#http-equiv
|
|
391
|
+
*/
|
|
392
|
+
type MetaHttpEquiv = 'content-security-policy' | 'content-type' | 'default-style' | 'x-ua-compatible' | 'refresh';
|
|
393
|
+
/**
|
|
394
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name
|
|
395
|
+
*/
|
|
396
|
+
type MetaName = 'application-name' | 'author' | 'description' | 'generator' | 'keywords' | 'referrer' | 'theme-color' | 'color-scheme' | 'viewport' | 'creator' | 'googlebot' | 'publisher' | 'robots';
|
|
397
|
+
/**
|
|
398
|
+
* @see https://ogp.me/
|
|
399
|
+
*/
|
|
400
|
+
type MetaProperty = 'og:title' | 'og:type' | 'og:image' | 'og:url' | 'og:audio' | 'og:description' | 'og:determiner' | 'og:locale' | 'og:locale:alternate' | 'og:site_name' | 'og:video' | 'og:image:url' | 'og:image:secure_url' | 'og:image:type' | 'og:image:width' | 'og:image:height' | 'og:image:alt';
|
|
384
401
|
interface MetaHTMLAttributes extends HTMLAttributes {
|
|
385
|
-
charset?:
|
|
386
|
-
'http-equiv'?:
|
|
387
|
-
name?:
|
|
402
|
+
charset?: LiteralUnion<'utf-8'> | undefined;
|
|
403
|
+
'http-equiv'?: LiteralUnion<MetaHttpEquiv> | undefined;
|
|
404
|
+
name?: LiteralUnion<MetaName> | undefined;
|
|
388
405
|
media?: string | undefined;
|
|
389
406
|
content?: string | undefined;
|
|
390
|
-
|
|
407
|
+
property?: LiteralUnion<MetaProperty> | undefined;
|
|
408
|
+
httpEquiv?: LiteralUnion<MetaHttpEquiv> | undefined;
|
|
391
409
|
}
|
|
392
410
|
interface MeterHTMLAttributes extends HTMLAttributes {
|
|
393
411
|
form?: string | undefined;
|
package/dist/utils/html.js
CHANGED
|
@@ -14,13 +14,14 @@ var escapeRe = /[&<>'"]/;
|
|
|
14
14
|
var stringBufferToString = async (buffer, callbacks) => {
|
|
15
15
|
let str = "";
|
|
16
16
|
callbacks ||= [];
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const resolvedBuffer = await Promise.all(buffer);
|
|
18
|
+
for (let i = resolvedBuffer.length - 1; ; i--) {
|
|
19
|
+
str += resolvedBuffer[i];
|
|
19
20
|
i--;
|
|
20
21
|
if (i < 0) {
|
|
21
22
|
break;
|
|
22
23
|
}
|
|
23
|
-
let r =
|
|
24
|
+
let r = resolvedBuffer[i];
|
|
24
25
|
if (typeof r === "object") {
|
|
25
26
|
callbacks.push(...r.callbacks || []);
|
|
26
27
|
}
|
|
@@ -3,7 +3,7 @@ import { getCookie } from "../helper/cookie/index.js";
|
|
|
3
3
|
import { HTTPException } from "../http-exception.js";
|
|
4
4
|
import { bufferToFormData } from "../utils/buffer.js";
|
|
5
5
|
var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
6
|
-
var multipartRegex = /^multipart\/form-data(
|
|
6
|
+
var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
|
|
7
7
|
var urlencodedRegex = /^application\/x-www-form-urlencoded$/;
|
|
8
8
|
var validator = (target, validationFunc) => {
|
|
9
9
|
return async (c, next) => {
|
|
@@ -42,12 +42,13 @@ var validator = (target, validationFunc) => {
|
|
|
42
42
|
const form = {};
|
|
43
43
|
formData.forEach((value2, key) => {
|
|
44
44
|
if (key.endsWith("[]")) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
;
|
|
46
|
+
(form[key] ??= []).push(value2);
|
|
47
|
+
} else if (Array.isArray(form[key])) {
|
|
48
|
+
;
|
|
49
|
+
form[key].push(value2);
|
|
50
|
+
} else if (key in form) {
|
|
51
|
+
form[key] = [form[key], value2];
|
|
51
52
|
} else {
|
|
52
53
|
form[key] = value2;
|
|
53
54
|
}
|