about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2023-09-24 07:18:15 +0200
committerAlan Pearce2023-09-24 07:18:15 +0200
commit3fca211a5e26a594fab44b3d84437ebaecc0124a (patch)
tree5c58fe771d66d39b5b80559d652c59278b8889e4 /src
parent406261d2305840d112ad75efb291259dd5e8b302 (diff)
downloadwebsite-3fca211a5e26a594fab44b3d84437ebaecc0124a.tar.lz
website-3fca211a5e26a594fab44b3d84437ebaecc0124a.tar.zst
website-3fca211a5e26a594fab44b3d84437ebaecc0124a.zip
Fix serving pre-compressed files
Diffstat (limited to 'src')
-rw-r--r--src/app.ts18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/app.ts b/src/app.ts
index 57ae71d..e03f50e 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -165,30 +165,24 @@ export const server = {
         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,
           });