From caeade853d49ba1ab47f545b1389473d724047f1 Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Tue, 11 Jul 2023 07:57:24 -0400 Subject: [PATCH] fix static file body --- run-serve.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run-serve.tsx b/run-serve.tsx index 828665e..1a37f8f 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -177,7 +177,7 @@ export const Transpile = if(key.endsWith("/") && inPath.startsWith(key) && key.length > bestLength) { bestKey = key; - bestLength = bestLength; + bestLength = key.length; } }); if(bestKey) @@ -207,7 +207,7 @@ export const Transpile = { const importStatement = match[0]; const importPath = remap(match[1].substring(1, match[1].length-1)); - const moduleName:string = `_dyn_${staticImports.length}`; + const moduleName = `_dyn_${staticImports.length}` as string; staticImports.push(`import ${moduleName} from ${importPath};`); convertedBody = convertedBody.replace(importStatement, `Promise.resolve(${moduleName})`); @@ -349,8 +349,7 @@ const server = Deno.serve({port:parseInt(Deno.env.get("port")||"8000")}, async(r { const type = MIME.typeByExtension(ext); const file = await fetch(Configuration.Proxy + url.pathname); - const text = await file.text(); - return new Response(text, {headers:{...headers, "content-type":type||""}}); + return new Response(file.body, {headers:{...headers, "content-type":type||""}}); } catch(e) {