fix: 修正中间件以确保在读取index.html之前检查文件是否存在

This commit is contained in:
2025-03-09 10:44:48 +08:00
parent 94ef3a71ee
commit f88543ad04

View File

@@ -186,7 +186,7 @@ async function default_handler(req: Request, ctx: FreshContext) {
if (!(await exists(p)) || normalize(p) === normalize(swagger_base)) {
p = join(swagger_base, "/index.html");
}
if (basename(p) == "index.html") {
if (basename(p) == "index.html" && await exists(p)) {
const html = await Deno.readTextFile(p);
await initDOMParser();
try {