@@ -337,3 +337,3 @@ // src/adapter/aws-lambda/handler.ts | ||
| var isProxyEventV2 = (event) => { | ||
| return Object.hasOwn(event, "rawPath"); | ||
| return Object.hasOwn(event, "rawPath") && Object.hasOwn(event.requestContext ?? {}, "http"); | ||
| }; | ||
@@ -340,0 +340,0 @@ var isLatticeEventV2 = (event) => { |
@@ -27,3 +27,5 @@ // src/adapter/bun/websocket.ts | ||
| url: new URL(c.req.url), | ||
| protocol: c.req.url | ||
| // The first requested subprotocol, exposed via WSContext.protocol to | ||
| // match the deno and cloudflare adapters. | ||
| protocol: c.req.header("sec-websocket-protocol")?.split(",")[0]?.trim() ?? "" | ||
| } | ||
@@ -30,0 +32,0 @@ }); |
@@ -367,3 +367,3 @@ var __defProp = Object.defineProperty; | ||
| const isProxyEventV2 = (event) => { | ||
| return Object.hasOwn(event, "rawPath"); | ||
| return Object.hasOwn(event, "rawPath") && Object.hasOwn(event.requestContext ?? {}, "http"); | ||
| }; | ||
@@ -370,0 +370,0 @@ const isLatticeEventV2 = (event) => { |
@@ -51,3 +51,5 @@ var __defProp = Object.defineProperty; | ||
| url: new URL(c.req.url), | ||
| protocol: c.req.url | ||
| // The first requested subprotocol, exposed via WSContext.protocol to | ||
| // match the deno and cloudflare adapters. | ||
| protocol: c.req.header("sec-websocket-protocol")?.split(",")[0]?.trim() ?? "" | ||
| } | ||
@@ -54,0 +56,0 @@ }); |
@@ -68,3 +68,3 @@ var __defProp = Object.defineProperty; | ||
| } | ||
| if (content) { | ||
| if (content != null) { | ||
| const mimeType = options.mimes && (0, import_mime.getMimeType)(path, options.mimes) || (0, import_mime.getMimeType)(path); | ||
@@ -71,0 +71,0 @@ c.header("Content-Type", mimeType || "application/octet-stream"); |
@@ -23,8 +23,10 @@ var __defProp = Object.defineProperty; | ||
| module.exports = __toCommonJS(body_exports); | ||
| var import_request = require("../request"); | ||
| var import_buffer = require("./buffer"); | ||
| const isRawRequest = (request) => "headers" in request; | ||
| const parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => { | ||
| const { all = false, dot = false } = options; | ||
| const headers = request instanceof import_request.HonoRequest ? request.raw.headers : request.headers; | ||
| const headers = isRawRequest(request) ? request.headers : request.raw.headers; | ||
| const contentType = headers.get("Content-Type"); | ||
| if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) { | ||
| const mediaType = contentType?.split(";")[0].trim().toLowerCase(); | ||
| if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") { | ||
| return parseFormData(request, { all, dot }); | ||
@@ -35,3 +37,9 @@ } | ||
| async function parseFormData(request, options) { | ||
| const formData = await request.formData(); | ||
| const headers = isRawRequest(request) ? request.headers : request.raw.headers; | ||
| const arrayBuffer = await request.arrayBuffer(); | ||
| const formDataPromise = (0, import_buffer.bufferToFormData)(arrayBuffer, headers.get("Content-Type") || ""); | ||
| if (!isRawRequest(request)) { | ||
| request.bodyCache.formData = formDataPromise; | ||
| } | ||
| const formData = await formDataPromise; | ||
| if (formData) { | ||
@@ -38,0 +46,0 @@ return convertFormDataToBodyData(formData, options); |
@@ -91,3 +91,4 @@ var __defProp = Object.defineProperty; | ||
| headers: { | ||
| "Content-Type": contentType | ||
| // Normalize the media type (case-insensitive) while keeping parameters like the boundary | ||
| "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) | ||
| } | ||
@@ -94,0 +95,0 @@ }); |
@@ -26,5 +26,5 @@ var __defProp = Object.defineProperty; | ||
| var import_buffer = require("../utils/buffer"); | ||
| const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
| const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/; | ||
| const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
| const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i; | ||
| const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i; | ||
| const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i; | ||
| const validator = (target, validationFunc) => { | ||
@@ -31,0 +31,0 @@ return async (c, next) => { |
@@ -47,3 +47,3 @@ // src/middleware/serve-static/index.ts | ||
| } | ||
| if (content) { | ||
| if (content != null) { | ||
| const mimeType = options.mimes && getMimeType(path, options.mimes) || getMimeType(path); | ||
@@ -50,0 +50,0 @@ c.header("Content-Type", mimeType || "application/octet-stream"); |
@@ -27,7 +27,7 @@ /** | ||
| * app.use(async (c, next) => { | ||
| * c.set('message', 'Hono is hot!!) | ||
| * c.set('message', 'Hono is hot!!') | ||
| * await next() | ||
| * }) | ||
| * | ||
| * app.get('/', async (c) => { c.text(getMessage()) }) | ||
| * app.get('/', async (c) => c.text(getMessage())) | ||
| * | ||
@@ -34,0 +34,0 @@ * const getMessage = () => { |
@@ -5,3 +5,3 @@ /** | ||
| */ | ||
| import { HonoRequest } from '../request'; | ||
| import type { HonoRequest } from '../request'; | ||
| type BodyDataValueDot = { | ||
@@ -8,0 +8,0 @@ [x: string]: string | File | BodyDataValueDot; |
+12
-4
| // src/utils/body.ts | ||
| import { HonoRequest } from "../request.js"; | ||
| import { bufferToFormData } from "./buffer.js"; | ||
| var isRawRequest = (request) => "headers" in request; | ||
| var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => { | ||
| const { all = false, dot = false } = options; | ||
| const headers = request instanceof HonoRequest ? request.raw.headers : request.headers; | ||
| const headers = isRawRequest(request) ? request.headers : request.raw.headers; | ||
| const contentType = headers.get("Content-Type"); | ||
| if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) { | ||
| const mediaType = contentType?.split(";")[0].trim().toLowerCase(); | ||
| if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") { | ||
| return parseFormData(request, { all, dot }); | ||
@@ -13,3 +15,9 @@ } | ||
| async function parseFormData(request, options) { | ||
| const formData = await request.formData(); | ||
| const headers = isRawRequest(request) ? request.headers : request.raw.headers; | ||
| const arrayBuffer = await request.arrayBuffer(); | ||
| const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || ""); | ||
| if (!isRawRequest(request)) { | ||
| request.bodyCache.formData = formDataPromise; | ||
| } | ||
| const formData = await formDataPromise; | ||
| if (formData) { | ||
@@ -16,0 +24,0 @@ return convertFormDataToBodyData(formData, options); |
@@ -67,3 +67,4 @@ // src/utils/buffer.ts | ||
| headers: { | ||
| "Content-Type": contentType | ||
| // Normalize the media type (case-insensitive) while keeping parameters like the boundary | ||
| "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) | ||
| } | ||
@@ -70,0 +71,0 @@ }); |
@@ -5,5 +5,5 @@ // src/validator/validator.ts | ||
| import { bufferToFormData } from "../utils/buffer.js"; | ||
| var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
| var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/; | ||
| var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
| var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i; | ||
| var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i; | ||
| var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i; | ||
| var validator = (target, validationFunc) => { | ||
@@ -10,0 +10,0 @@ return async (c, next) => { |
+8
-7
| { | ||
| "name": "hono", | ||
| "version": "4.12.27", | ||
| "version": "4.12.28", | ||
| "description": "Web framework built on Web Standards", | ||
@@ -10,3 +10,4 @@ "main": "dist/cjs/index.js", | ||
| "files": [ | ||
| "dist" | ||
| "dist", | ||
| "!dist/**/*.tsbuildinfo" | ||
| ], | ||
@@ -682,3 +683,3 @@ "scripts": { | ||
| "msw": "^2.6.0", | ||
| "np": "10.2.0", | ||
| "np": "11.2.1", | ||
| "oxc-parser": "^0.96.0", | ||
@@ -689,7 +690,7 @@ "pkg-pr-new": "^0.0.53", | ||
| "typescript": "^5.9.2", | ||
| "undici": "^6.21.3", | ||
| "undici": "^6.27.0", | ||
| "vite-plugin-fastly-js-compute": "^0.4.2", | ||
| "vitest": "^4.1.7", | ||
| "wrangler": "4.12.0", | ||
| "ws": "^8.18.0", | ||
| "vitest": "^4.1.9", | ||
| "wrangler": "4.107.0", | ||
| "ws": "^8.21.0", | ||
| "zod": "^3.23.8" | ||
@@ -696,0 +697,0 @@ }, |
Sorry, the diff of this file is not supported yet
37574
0.06%1351903
-5.18%562
-0.18%