all repos — website @ 3fca211a5e26a594fab44b3d84437ebaecc0124a

My website

Fix serving pre-compressed files

Alan Pearce
commit

3fca211a5e26a594fab44b3d84437ebaecc0124a

parent

406261d2305840d112ad75efb291259dd5e8b302

1 file changed, 6 insertions(+), 12 deletions(-)

changed files
M src/app.tssrc/app.ts
@@ -165,30 +165,24 @@ });
const encodings = (request.headers.get("accept-encoding") || "") .split(",") .map((x) => x.trim().toLowerCase()); - if (encodings.includes("br") && files.has(file.relPath + ".br")) { + if (encodings.includes("br") && files.has(pathname + ".br")) { transaction.setHttpStatus(200); transaction.setTag("http.content-encoding", "br"); - return serveFile(files.get(file.relPath + ".br"), 200, { + return serveFile(files.get(pathname + ".br"), 200, { "content-encoding": "br", "content-type": file.type, }); - } else if ( - encodings.includes("zstd") && - files.has(file.relPath + ".zst") - ) { + } else if (encodings.includes("zstd") && files.has(pathname + ".zst")) { transaction.setHttpStatus(200); transaction.setTag("http.content-encoding", "zstd"); - return serveFile(files.get(file.relPath + ".zst"), 200, { + return serveFile(files.get(pathname + ".zst"), 200, { "content-encoding": "zstd", "content-type": file.type, }); - } else if ( - encodings.includes("gzip") && - files.has(file.relPath + ".gz") - ) { + } else if (encodings.includes("gzip") && files.has(pathname + ".gz")) { transaction.setHttpStatus(200); transaction.setTag("http.content-encoding", "gzip"); - return serveFile(files.get(file.relPath + ".gz"), 200, { + return serveFile(files.get(pathname + ".gz"), 200, { "content-encoding": "gzip", "content-type": file.type, });