diff --git a/core/terminal.js b/core/terminal.js index 14dc7360..00946ca5 100644 --- a/core/terminal.js +++ b/core/terminal.js @@ -237,18 +237,21 @@ async function handler(request, response, packageOwner, packageName, uri) { for (var i in kStaticFiles) { if (uri === kStaticFiles[i].uri) { found = true; - var data = new TextDecoder("UTF-8").decode(File.readFile("core/" + kStaticFiles[i].path)); - if (kStaticFiles[i].uri == "") { - if (gGlobalSettings && gGlobalSettings['google-signin-client_id']) { - data = data.replace("", ` + var data = File.readFile("core/" + kStaticFiles[i].path); + if (kStaticFiles[i].type.indexOf("text/") == 0) { + data = new TextDecoder("UTF-8").decode(data); + if (kStaticFiles[i].uri == "") { + if (gGlobalSettings && gGlobalSettings['google-signin-client_id']) { + data = data.replace("", ` `); + } + data = data.replace("$(VIEW_SOURCE)", "/~" + packageOwner + "/" + packageName + "/view"); } - data = data.replace("$(VIEW_SOURCE)", "/~" + packageOwner + "/" + packageName + "/view"); + data = new TextEncoder("UTF-8").encode(data); } - var raw = new TextEncoder("UTF-8").encode(data); - response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": raw.length}); - response.end(raw); + response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": data.length}); + response.end(data); break; } }