// --------------------------------------------------------------------------- // Every old umtool page address, and where it lives now. // // ONE table, read by two things (plans/umtool-redesign.md, "Redirects"): // - next.config.ts's `redirects()`, which answers them. Next checks redirects // BEFORE the filesystem, so a row here beats a page still at the old path, // and the query string is passed through to the destination unchanged. // - e2e/redirects.spec.ts (P3), which requests every `source` with // `maxRedirects: 0` and checks the status and the Location. // // A row is Next's own redirect shape // (node_modules/next/dist/docs/01-app/03-api-reference/05-config/01-next-config-js/redirects.md): // // { // source: "/browse/:path*", // path-to-regexp; `:x*` zero or more segments // destination: "/projects/:path*", // matched parameters carry over // permanent: true, // 308 since P6b (307 before). A browser // // caches a 308 forever, so a row is never // // repointed or removed: the old address // // must keep landing where it said // has: [{ type: "query", key: "from" }], // optional: only when the query has `from` // phase: "P3", // ours, not Next's: which phase added it. // // next.config.ts strips it. // } // // ORDER MATTERS: Next takes the first match, so a reserved `/browse/` row // goes BEFORE the `/browse/:path*` catch-all. Every page address lib/hrefs.ts // builds is either still served or has a row here. // --------------------------------------------------------------------------- /** @typedef {{ type: "query" | "header" | "cookie", key: string, value?: string }} RedirectMatch */ /** * @typedef {{ * source: string, * destination: string, * permanent: boolean, * has?: RedirectMatch[], * missing?: RedirectMatch[], * phase: string, * }} RedirectRow */ // Every row is permanent (308) since P6b: the moves are settled. const p3 = (source, destination) => ({ source, destination, permanent: true, phase: "P3" }); const p5 = (source, destination, extra = {}) => ({ source, destination, permanent: true, ...extra, phase: "P5" }); const p6 = (source, destination) => ({ source, destination, permanent: true, phase: "P6" }); /** @type {RedirectRow[]} */ export const REDIRECTS = [ // The editor's "make a video" hand-off (VideoPanel, VideoNavStrip link // `/?from=/`): only when the query HAS `from`, so the Inbox // itself is untouched. The query is passed through, so it lands on // /create?from=/, which opens "Video from a recording" prefilled. p5("/", "/create", { has: [{ type: "query", key: "from" }] }), // The new-article form is Create's "Article from a question". p5("/articles/new", "/create?make=article"), // The proof of concept's new-article page (release 27), deleted in P6. p6("/drafts", "/create?make=article"), // The project list became Work; the decision list became the Inbox. p3("/browse", "/work"), p3("/browse/decisions", "/"), // The tool pages that were static children of /browse -- BEFORE the // catch-all, which would send them to a project of that name. p3("/browse/find", "/tools/find"), p3("/browse/faces", "/tools/faces"), p3("/browse/sources", "/tools/sources"), p3("/browse/trim/:set", "/tools/trim/:set"), // The escape hatch for a project with no address of its own (a name that // cannot be a URL segment, or one that is `at`). p3("/browse/at", "/projects/at"), // Every project, cut and bench: /browse/[/…] → /projects/[/…]. p3("/browse/:path*", "/projects/:path*"), // The article lists are Work's facets now. /articles was the article // store's list, so it lands on the store's articles (site `articles`). p3("/articles", "/work?kind=article&site=articles"), p3("/sites", "/work?by=site"), // The song tools. p3("/mix", "/tools/mix"), p3("/:mode(sort|salvage|verify|keeps)", "/tools/song/:mode"), // Release 28's verdict bench. p3("/bench", "/tools/bench"), ]; /** The rows in the shape next.config.ts's `redirects()` returns. */ export function nextRedirects() { return REDIRECTS.map(({ phase: _phase, ...row }) => row); }