Fix bad encoding of static files.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3395 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2017-03-01 22:44:30 +00:00
parent a47043955e
commit 3ca8659bba

View File

@ -237,7 +237,9 @@ 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));
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("<!--HEAD-->", `
@ -246,9 +248,10 @@ async function handler(request, response, packageOwner, packageName, uri) {
}
data = data.replace("$(VIEW_SOURCE)", "/~" + packageOwner + "/" + packageName + "/view");
}
var raw = new TextEncoder("UTF-8").encode(data);
response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": raw.length});
response.end(raw);
data = new TextEncoder("UTF-8").encode(data);
}
response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": data.length});
response.end(data);
break;
}
}