Merge pull request 'Verify canonical document source URLs without redirects' (#50) from codex/verify-canonical-doc-routes into main
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 13m16s
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 13m16s
Reviewed-on: #50
This commit was merged in pull request #50.
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user