about summary refs log tree commit diff stats
path: root/src/app.ts
diff options
context:
space:
mode:
authorAlan Pearce2024-04-01 19:53:58 +0200
committerAlan Pearce2024-04-01 19:53:58 +0200
commitf9b4f8dc9b3e918d577bf61763e3b9cf1f0a7891 (patch)
treef344295e8cfc09ac6ae5845f5a0e439fb4c0b4cc /src/app.ts
parent6cabd370fc9d22e5b15c4627eaf1660ae7cafc33 (diff)
downloadwebsite-f9b4f8dc9b3e918d577bf61763e3b9cf1f0a7891.tar.lz
website-f9b4f8dc9b3e918d577bf61763e3b9cf1f0a7891.tar.zst
website-f9b4f8dc9b3e918d577bf61763e3b9cf1f0a7891.zip
Redirect existing index.html files
Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/app.ts b/src/app.ts
index 1b8bcf7..f41d6f2 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -214,6 +214,17 @@ export const server = {
             status: status,
             headers: { location: newpath },
           });
+        } else if (files.has(pathname.replace(/index.html$/, ""))) {
+          newpath = pathname.replace(/index.html$/, "");
+          metrics.requests.inc({
+            method: request.method,
+            path: newpath,
+            status_code: (status = 302),
+          });
+          return new Response("", {
+            status: status,
+            headers: { location: newpath },
+          });
         }
         metrics.requests.inc({
           method: request.method,