Comparing version 4.5.10 to 4.5.11
@@ -274,3 +274,3 @@ "use strict"; | ||
); | ||
} else if (tag === "svg") { | ||
} else if (tag === "svg" || tag === "head") { | ||
nameSpaceContext ||= (0, import_context.createContext)(""); | ||
@@ -277,0 +277,0 @@ return new JSXNode(tag, props, [ |
@@ -74,7 +74,7 @@ "use strict"; | ||
const caught = false; | ||
const catchCallback = ({ error, buffer }) => { | ||
const catchCallback = ({ error: error2, buffer }) => { | ||
if (caught) { | ||
return ""; | ||
} | ||
const fallbackResString = fallbackRes(error); | ||
const fallbackResString = fallbackRes(error2); | ||
if (buffer) { | ||
@@ -93,2 +93,4 @@ buffer[0] = buffer[0].replace(replaceRe, fallbackResString); | ||
}; | ||
let error; | ||
const promiseAll = Promise.all(resArray).catch((e) => error = e); | ||
return (0, import_html.raw)(`<template id="E:${index}"></template><!--E:${index}-->`, [ | ||
@@ -99,3 +101,6 @@ ({ phase, buffer, context }) => { | ||
} | ||
return Promise.all(resArray).then(async (htmlArray) => { | ||
return promiseAll.then(async (htmlArray) => { | ||
if (error) { | ||
throw error; | ||
} | ||
htmlArray = htmlArray.flat(); | ||
@@ -156,6 +161,6 @@ const content = htmlArray.join(""); | ||
); | ||
}).catch((error) => catchCallback({ error, buffer })) | ||
}).catch((error2) => catchCallback({ error: error2, buffer })) | ||
); | ||
return (0, import_html.raw)(html, promises); | ||
}).catch((error) => catchCallback({ error, buffer })); | ||
}).catch((error2) => catchCallback({ error: error2, buffer })); | ||
} | ||
@@ -162,0 +167,0 @@ ]); |
@@ -110,4 +110,11 @@ "use strict"; | ||
const nameSpaceContext = (0, import_base.getNameSpaceContext)(); | ||
if (nameSpaceContext && (0, import_context.useContext)(nameSpaceContext) === "svg") { | ||
new import_base.JSXNode("title", props, (0, import_children.toArray)(children ?? [])); | ||
if (nameSpaceContext) { | ||
const context = (0, import_context.useContext)(nameSpaceContext); | ||
if (context === "svg" || context === "head") { | ||
return new import_base.JSXNode( | ||
"title", | ||
props, | ||
(0, import_children.toArray)(children ?? []) | ||
); | ||
} | ||
} | ||
@@ -120,3 +127,4 @@ return documentMetadataTag("title", children, props, false); | ||
}) => { | ||
if (["src", "async"].some((k) => !props[k])) { | ||
const nameSpaceContext = (0, import_base.getNameSpaceContext)(); | ||
if (["src", "async"].some((k) => !props[k]) || nameSpaceContext && (0, import_context.useContext)(nameSpaceContext) === "head") { | ||
return returnWithoutSpecialBehavior("script", children, props); | ||
@@ -144,2 +152,6 @@ } | ||
const meta = ({ children, ...props }) => { | ||
const nameSpaceContext = (0, import_base.getNameSpaceContext)(); | ||
if (nameSpaceContext && (0, import_context.useContext)(nameSpaceContext) === "head") { | ||
return returnWithoutSpecialBehavior("meta", children, props); | ||
} | ||
return documentMetadataTag("meta", children, props, false); | ||
@@ -146,0 +158,0 @@ }; |
@@ -25,22 +25,4 @@ "use strict"; | ||
var import_http_exception = require("../../http-exception"); | ||
var import_basic_auth = require("../../utils/basic-auth"); | ||
var import_buffer = require("../../utils/buffer"); | ||
var import_encode = require("../../utils/encode"); | ||
const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/; | ||
const USER_PASS_REGEXP = /^([^:]*):(.*)$/; | ||
const utf8Decoder = new TextDecoder(); | ||
const auth = (req) => { | ||
const match = CREDENTIALS_REGEXP.exec(req.header("Authorization") || ""); | ||
if (!match) { | ||
return void 0; | ||
} | ||
let userPass = void 0; | ||
try { | ||
userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode((0, import_encode.decodeBase64)(match[1]))); | ||
} catch { | ||
} | ||
if (!userPass) { | ||
return void 0; | ||
} | ||
return { username: userPass[1], password: userPass[2] }; | ||
}; | ||
const basicAuth = (options, ...users) => { | ||
@@ -61,3 +43,3 @@ const usernamePasswordInOptions = "username" in options && "password" in options; | ||
return async function basicAuth2(ctx, next) { | ||
const requestUser = auth(ctx.req); | ||
const requestUser = (0, import_basic_auth.auth)(ctx.req.raw); | ||
if (requestUser) { | ||
@@ -64,0 +46,0 @@ if (verifyUserInOptions) { |
@@ -29,3 +29,3 @@ "use strict"; | ||
const contentType = headers.get("Content-Type"); | ||
if (contentType !== null && contentType.startsWith("multipart/form-data") || contentType !== null && contentType.startsWith("application/x-www-form-urlencoded")) { | ||
if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) { | ||
return parseFormData(request, { all, dot }); | ||
@@ -32,0 +32,0 @@ } |
@@ -237,3 +237,3 @@ // src/jsx/base.ts | ||
); | ||
} else if (tag === "svg") { | ||
} else if (tag === "svg" || tag === "head") { | ||
nameSpaceContext ||= createContext(""); | ||
@@ -240,0 +240,0 @@ return new JSXNode(tag, props, [ |
@@ -51,7 +51,7 @@ // src/jsx/components.ts | ||
const caught = false; | ||
const catchCallback = ({ error, buffer }) => { | ||
const catchCallback = ({ error: error2, buffer }) => { | ||
if (caught) { | ||
return ""; | ||
} | ||
const fallbackResString = fallbackRes(error); | ||
const fallbackResString = fallbackRes(error2); | ||
if (buffer) { | ||
@@ -70,2 +70,4 @@ buffer[0] = buffer[0].replace(replaceRe, fallbackResString); | ||
}; | ||
let error; | ||
const promiseAll = Promise.all(resArray).catch((e) => error = e); | ||
return raw(`<template id="E:${index}"></template><!--E:${index}-->`, [ | ||
@@ -76,3 +78,6 @@ ({ phase, buffer, context }) => { | ||
} | ||
return Promise.all(resArray).then(async (htmlArray) => { | ||
return promiseAll.then(async (htmlArray) => { | ||
if (error) { | ||
throw error; | ||
} | ||
htmlArray = htmlArray.flat(); | ||
@@ -133,6 +138,6 @@ const content = htmlArray.join(""); | ||
); | ||
}).catch((error) => catchCallback({ error, buffer })) | ||
}).catch((error2) => catchCallback({ error: error2, buffer })) | ||
); | ||
return raw(html, promises); | ||
}).catch((error) => catchCallback({ error, buffer })); | ||
}).catch((error2) => catchCallback({ error: error2, buffer })); | ||
} | ||
@@ -139,0 +144,0 @@ ]); |
@@ -81,4 +81,11 @@ // src/jsx/intrinsic-element/components.ts | ||
const nameSpaceContext = getNameSpaceContext(); | ||
if (nameSpaceContext && useContext(nameSpaceContext) === "svg") { | ||
new JSXNode("title", props, toArray(children ?? [])); | ||
if (nameSpaceContext) { | ||
const context = useContext(nameSpaceContext); | ||
if (context === "svg" || context === "head") { | ||
return new JSXNode( | ||
"title", | ||
props, | ||
toArray(children ?? []) | ||
); | ||
} | ||
} | ||
@@ -91,3 +98,4 @@ return documentMetadataTag("title", children, props, false); | ||
}) => { | ||
if (["src", "async"].some((k) => !props[k])) { | ||
const nameSpaceContext = getNameSpaceContext(); | ||
if (["src", "async"].some((k) => !props[k]) || nameSpaceContext && useContext(nameSpaceContext) === "head") { | ||
return returnWithoutSpecialBehavior("script", children, props); | ||
@@ -115,2 +123,6 @@ } | ||
var meta = ({ children, ...props }) => { | ||
const nameSpaceContext = getNameSpaceContext(); | ||
if (nameSpaceContext && useContext(nameSpaceContext) === "head") { | ||
return returnWithoutSpecialBehavior("meta", children, props); | ||
} | ||
return documentMetadataTag("meta", children, props, false); | ||
@@ -117,0 +129,0 @@ }; |
// src/middleware/basic-auth/index.ts | ||
import { HTTPException } from "../../http-exception.js"; | ||
import { auth } from "../../utils/basic-auth.js"; | ||
import { timingSafeEqual } from "../../utils/buffer.js"; | ||
import { decodeBase64 } from "../../utils/encode.js"; | ||
var CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/; | ||
var USER_PASS_REGEXP = /^([^:]*):(.*)$/; | ||
var utf8Decoder = new TextDecoder(); | ||
var auth = (req) => { | ||
const match = CREDENTIALS_REGEXP.exec(req.header("Authorization") || ""); | ||
if (!match) { | ||
return void 0; | ||
} | ||
let userPass = void 0; | ||
try { | ||
userPass = USER_PASS_REGEXP.exec(utf8Decoder.decode(decodeBase64(match[1]))); | ||
} catch { | ||
} | ||
if (!userPass) { | ||
return void 0; | ||
} | ||
return { username: userPass[1], password: userPass[2] }; | ||
}; | ||
var basicAuth = (options, ...users) => { | ||
@@ -38,3 +20,3 @@ const usernamePasswordInOptions = "username" in options && "password" in options; | ||
return async function basicAuth2(ctx, next) { | ||
const requestUser = auth(ctx.req); | ||
const requestUser = auth(ctx.req.raw); | ||
if (requestUser) { | ||
@@ -41,0 +23,0 @@ if (verifyUserInOptions) { |
@@ -20,3 +20,3 @@ /** | ||
* | ||
* @see {@link{https://hono.dev/docs/middleware/builtin/jsx-renderer}} | ||
* @see {@link https://hono.dev/docs/middleware/builtin/jsx-renderer} | ||
* | ||
@@ -23,0 +23,0 @@ * @param {ComponentWithChildren} [component] - The component to render, which can accept children and props. |
@@ -7,3 +7,3 @@ // src/utils/body.ts | ||
const contentType = headers.get("Content-Type"); | ||
if (contentType !== null && contentType.startsWith("multipart/form-data") || contentType !== null && contentType.startsWith("application/x-www-form-urlencoded")) { | ||
if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) { | ||
return parseFormData(request, { all, dot }); | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "hono", | ||
"version": "4.5.10", | ||
"version": "4.5.11", | ||
"description": "Web framework built on Web Standards", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -74,3 +74,3 @@ <div align="center"> | ||
- Create third-party middleware - Instruct below. | ||
- Share - Share your thoughts on the Blog, Twitter, and others. | ||
- Share - Share your thoughts on the Blog, X, and others. | ||
- Make your application - Please try to use Hono. | ||
@@ -77,0 +77,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1018583
490
28821