about summary refs log tree commit diff stats
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/index.ts b/src/index.ts
index d4c7b3d..7a2c5f5 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -24,6 +24,7 @@ type File = {
   handle: BunFile;
   relPath: string;
   headers?: Record<string, string>;
+  type: string;
   size: number;
   mtime: Date;
 };
@@ -67,10 +68,12 @@ function registerFile(
   if (files.get(pathname) !== undefined) {
     console.warn("File already registered:", pathname);
   }
+  const handle = Bun.file(filename);
   files.set(pathname, {
     filename,
     relPath: "/" + path,
-    handle: Bun.file(filename),
+    handle: handle,
+    type: pathname.startsWith("/feed-styles") ? "text/xsl" : handle.type,
     headers:
       pathname === "/404.html"
         ? Object.assign({}, defaultHeaders, { "cache-control": "no-cache" })
@@ -185,7 +188,7 @@ const server = Bun.serve({
           span.setTag("http.status_code", 200);
           return serveFile(files.get(file.relPath + ".br"), 200, {
             "content-encoding": "br",
-            "content-type": file.handle.type,
+            "content-type": file.type,
           });
         } else if (
           encodings.includes("zstd") &&
@@ -195,7 +198,7 @@ const server = Bun.serve({
           span.setTag("http.status_code", 200);
           return serveFile(files.get(file.relPath + ".zst"), 200, {
             "content-encoding": "zstd",
-            "content-type": file.handle.type,
+            "content-type": file.type,
           });
         } else if (
           encodings.includes("gzip") &&
@@ -205,7 +208,7 @@ const server = Bun.serve({
           span.setTag("http.status_code", 200);
           return serveFile(files.get(file.relPath + ".gz"), 200, {
             "content-encoding": "gzip",
-            "content-type": file.handle.type,
+            "content-type": file.type,
           });
         }
         span.setTag("http.encoding", "identity");