From 4e9ff808285fae1869d2ea619a9651a97b5fcdd7 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Wed, 4 Nov 2026 21:46:13 +0800 Subject: [PATCH] Verify canonical document source URLs without redirects --- apps/docs/scripts/auth-cli.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/docs/scripts/auth-cli.ts b/apps/docs/scripts/auth-cli.ts index 55507d6..78f376c 100644 --- a/apps/docs/scripts/auth-cli.ts +++ b/apps/docs/scripts/auth-cli.ts @@ -200,11 +200,15 @@ async function main() { for (const doc of searchIndex as { slug: string; sourceSlug: string }[]) { assert.ok(!doc.slug.split("/").some((part) => /^\d+-/.test(part)), doc.slug); const legacy = await request(`/docs/${doc.sourceSlug}?from=legacy`, { headers }); - assert.equal(legacy.status, 308, doc.sourceSlug); - const destination = new URL(legacy.headers.get("location")!, base); - assert.equal(destination.pathname, `/docs/${doc.slug}`); - assert.equal(destination.searchParams.get("from"), "legacy"); assert.ok(legacy.headers.get("cache-control")?.includes("no-store")); + if (doc.sourceSlug === doc.slug) { + assert.equal(legacy.status, 200, doc.sourceSlug); + } else { + assert.equal(legacy.status, 308, doc.sourceSlug); + const destination = new URL(legacy.headers.get("location")!, base); + assert.equal(destination.pathname, `/docs/${doc.slug}`); + assert.equal(destination.searchParams.get("from"), "legacy"); + } } const routes = ["/", ...searchIndex.map((doc: { slug: string }) => `/docs/${doc.slug}`)]; const raw = await request("/api/documents/source?slug=endor/endor-purpose-draft", { headers });