Skip to content

Commit

Permalink
308
Browse files Browse the repository at this point in the history
  • Loading branch information
rossrobino committed Feb 7, 2025
1 parent ce63898 commit 35ec2a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/docs/src/server/+func.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ export const prerender: Prerender = new Set([
export const handler: Handler = async (req) => {
const url = new URL(req.url);

// append trailing slash
if (url.pathname.at(-1) !== "/") {
url.pathname += "/";
url.search = "";
return Response.redirect(url.origin, 301);
}

const page = new Injector(html);

if (url.pathname === "/") {
Expand Down Expand Up @@ -103,6 +96,13 @@ export const handler: Handler = async (req) => {

if (!page.empty) return page.toResponse();

// append trailing slash
if (url.pathname.at(-1) !== "/") {
url.pathname += "/";
url.search = "";
return Response.redirect(url.origin, 308);
}

// redirect from old docs
if (url.pathname.startsWith("/docs/")) {
const element = url.pathname.split("/").at(2);
Expand All @@ -116,7 +116,7 @@ export const handler: Handler = async (req) => {

url.search = "";

return Response.redirect(url, 301);
return Response.redirect(url, 308);
}
}

Expand Down

0 comments on commit 35ec2a4

Please sign in to comment.