[WIP] A (somewhat barebones) atproto app for creating custom sites without hosting!

server: remove stupid no / ending thing because that was stupid.

Might make 404 redirect to sans / if it cant find a route tho and then falling back to 404
this makes no trailing slash the sane default but allows opt in trailing slash for certain urls

+11 -13
+11 -13
src/user.ts
··· 114 114 pds: string, 115 115 route: string 116 116 ): Promise<Response> { 117 - // if the url ends in `/` (and isnt the root), perma redirect to unslashed version 118 - // rationale: /dvd/ is the folder dvd, /index.html/ looks Weird 119 - // atcities.dev won't do folder listings (in v0.1 at least) because that requires finding EVERY rkey 120 - 121 - if (route !== "/" && route.endsWith("/")) 122 - return new Response(undefined, { 123 - status: 308, 124 - statusText: "Permanent Redirect", 125 - headers: { 126 - Location: route.slice(0, -1), 127 - }, 128 - }); 129 - 130 117 // get client to pds 131 118 const client = new Client({ 132 119 handler: simpleFetchHandler({ service: pds }), ··· 157 144 case "RecordNotFound": { 158 145 // 404 error so try load 404 page 159 146 if (route !== "404") { 147 + // try remove trailing / to see if that works 148 + // if that fails it'll get a 404 anyway 149 + if (route !== "/" && route.endsWith("/")) 150 + return new Response(undefined, { 151 + status: 308, 152 + statusText: "Permanent Redirect", 153 + headers: { 154 + Location: route.slice(0, -1), 155 + }, 156 + }); 157 + 160 158 const r404 = await getRoute(did, pds, "404"); 161 159 return new Response(r404.body, { 162 160 status: 404,