Skip to content

Commit 4f37df6

Browse files
committed
Verify Markdown redirects preserve queries after the Blume update
1 parent 30d59f1 commit 4f37df6

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎scripts/redirect-rules.mjs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ function unbased(route) {
3636
return route.slice(deploymentBase.length) || "/";
3737
}
3838

39-
// Retired pages in redirects.ts survive only as Blume meta-refresh stubs, and
40-
// moved pages leave no file behind, so neither has a Markdown twin. llms.txt
41-
// tells agents to append `.md` to any docs URL, so each one gets a real 301
42-
// from its `.md` URL to the replacement's `.md`.
39+
// Blume emits HTML meta-refresh stubs for retired Markdown URLs. Agents need
40+
// an HTTP redirect instead of HTML at those URLs. Moved pages also need a rule,
41+
// so both kinds get a 301 to the replacement's Markdown file.
4342
export const markdownTwinRules = [
4443
...authoredRedirectRules.map(({ from, to }) => ({ from: unbased(from), to: unbased(to) })),
4544
...retiredPageRedirects,

‎scripts/verify-routes.mjs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,16 @@ for (const [route, target, hopCount] of [
508508
for (const { from, to } of markdownTwinRules) {
509509
const matched = matchRedirect({
510510
compilation,
511-
request: { url: new URL(`${docsRoot}${from.slice(deploymentBase.length)}`), headers: new Headers() },
511+
request: {
512+
url: new URL(`${docsRoot}${from.slice(deploymentBase.length)}?source=markdown&value=a%2Fb`),
513+
headers: new Headers(),
514+
},
512515
});
513-
if (matched?.action !== "redirect" || matched.status !== 301 || matched.target !== to) {
516+
const destination = matched?.action === "redirect" ? new URL(matched.target, docsRoot) : null;
517+
if (
518+
matched?.action !== "redirect" || matched.status !== 301 ||
519+
destination?.pathname !== to || destination.search !== "?source=markdown&value=a%2Fb"
520+
) {
514521
throw new Error(`A retired page's Markdown URL must 301 to its replacement: ${from} -> ${to}`);
515522
}
516523
await requireFile(localTargetFor(to.slice(deploymentBase.length)));

0 commit comments

Comments
 (0)