@hono/vite-dev-server
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -56,3 +56,3 @@ import { getRequestListener } from "@hono/node-server"; | ||
} | ||
const response = await app.fetch(request, env, { | ||
let response = await app.fetch(request, env, { | ||
waitUntil: async (fn) => fn, | ||
@@ -63,2 +63,7 @@ passThroughOnException: () => { | ||
}); | ||
if (!(response instanceof Response)) { | ||
const message = 'The response is not an instance of "Response", but: ' + response; | ||
console.error(message); | ||
response = createErrorResponse(message); | ||
} | ||
if (options?.injectClientScript !== false && response.headers.get("content-type")?.match(/^text\/html/)) { | ||
@@ -77,2 +82,18 @@ const script = '<script>import("/@vite/client")</script>'; | ||
} | ||
function escapeHtml(str) { | ||
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"); | ||
} | ||
function createErrorResponse(body) { | ||
return new Response( | ||
`<html><body><pre style="white-space:pre-wrap;">${escapeHtml( | ||
body.toString() | ||
)}</pre></body></html>`, | ||
{ | ||
status: 500, | ||
headers: { | ||
"content-type": "text/html;charset=utf-8" | ||
} | ||
} | ||
); | ||
} | ||
function injectStringToResponse(response, content) { | ||
@@ -79,0 +100,0 @@ const stream = response.body; |
{ | ||
"name": "@hono/vite-dev-server", | ||
"description": "Vite dev-server plugin for Hono", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"types": "dist/index.d.ts", | ||
@@ -77,5 +77,5 @@ "module": "dist/index.js", | ||
"@hono/node-server": "^1.2.0", | ||
"miniflare": "^3.20231016.0", | ||
"miniflare": "^3.20231030.4", | ||
"minimatch": "^9.0.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
28830
555
Updatedminiflare@^3.20231030.4