From 8215186f2477fb0c5bdf732bb49627a352cbe6d7 Mon Sep 17 00:00:00 2001 From: vitoUwu Date: Wed, 30 Oct 2024 11:18:39 -0400 Subject: [PATCH] feat: add "found" status to redirects --- compat/std/loaders/x/redirects.ts | 2 +- website/handlers/redirect.ts | 3 ++- website/loaders/redirectsFromCsv.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/compat/std/loaders/x/redirects.ts b/compat/std/loaders/x/redirects.ts index 63ff66640..709865f12 100644 --- a/compat/std/loaders/x/redirects.ts +++ b/compat/std/loaders/x/redirects.ts @@ -11,7 +11,7 @@ export interface Redirect { * @description Path is url pattern. https://developer.mozilla.org/en-US/docs/Web/API/URL_Pattern_API */ to: string; - type?: "temporary" | "permanent"; + type?: "temporary" | "permanent" | "found"; /** * @title Discard query parameters */ diff --git a/website/handlers/redirect.ts b/website/handlers/redirect.ts index 21ed52136..5162e2756 100644 --- a/website/handlers/redirect.ts +++ b/website/handlers/redirect.ts @@ -3,7 +3,7 @@ import { isFreshCtx } from "./fresh.ts"; type ConnInfo = Deno.ServeHandlerInfo; export interface RedirectConfig { to: string; - type?: "permanent" | "temporary"; + type?: "permanent" | "temporary" | "found"; discardQueryParameters?: boolean; } @@ -20,6 +20,7 @@ export default function Redirect( number > = { "temporary": 307, + "found": 302, "permanent": 301, }; diff --git a/website/loaders/redirectsFromCsv.ts b/website/loaders/redirectsFromCsv.ts index fe6d09028..c539d34eb 100644 --- a/website/loaders/redirectsFromCsv.ts +++ b/website/loaders/redirectsFromCsv.ts @@ -1,14 +1,14 @@ import { join } from "std/path/mod.ts"; import { Route } from "../flags/audience.ts"; -const REDIRECT_TYPE_ENUM = ["temporary", "permanent"]; +const REDIRECT_TYPE_ENUM = ["temporary", "permanent", "found"]; const CONCATENATE_PARAMS_VALUES = ["true", "false"]; /** @titleBy from */ export interface Redirect { from: string; to: string; - type?: "temporary" | "permanent"; + type?: "temporary" | "permanent" | "found"; discardQueryParameters?: boolean; }