Repository navigation
Preserve URL fragments through static docs redirects - #78608
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
🟡 Changes recommended
The unsupported-destination test can pass on an unrelated missing-meta-tag error, so it must assert the expected validation error to protect the destination guards.
1 open issue
What changed in this PR
Preserves section bookmarks when moved documentation pages redirect, addressing #78587 through an Astro post-build integration.
Changes:
- Inserts fragment-preserving JavaScript into verified static redirect pages, honoring destination fragments and retaining the meta-refresh fallback.
- Adds HTML rewrite unit tests and built-site browser regressions.
- Documents supported redirect formats, validation failures, and no-JavaScript limitations.
| File | Description |
|---|---|
docs/tests/section-sidebar.spec.ts |
Adds browser regressions for fragment preservation and precedence. |
docs/src/lib/redirect-fragments.test.js |
Tests rewriting, validation, escaping, and build-hook behavior. |
docs/src/lib/redirect-fragments.js |
Implements verified redirect rewriting after builds. |
docs/README.md |
Explains redirect behavior, limitations, and unit-test usage. |
docs/astro.config.mjs |
Registers the redirect-fragment integration. |
Review effort: Balanced (adaptive)
|
|
||
| test("rejects unsupported or ambiguous destinations", () => { | ||
| for (const destination of ["javascript:alert(1)", " javascript:alert(1)", "java\nscript:alert(1)", "//evil.example/x", "/\\evil.example/x", "relative/path", "mailto:[email protected]", "/a b/"]) { | ||
| assert.throws(() => addFragmentScript("", destination)); |
There was a problem hiding this comment.
Updated the unsupported-destination cases to assert the corresponding destination-validation error, so a missing-meta-refresh error can no longer satisfy them. Committed as b385ffd.
There was a problem hiding this comment.
Impeccable review: Preserve URL fragments through static docs redirects
Verdict: non-blocking. The integration logic is sound.
Verified
node --test src/lib/redirect-fragments.test.js: 8/8 pass.- The committed destination regex and all 178 configured string redirects pass
projectRedirects. - Head SHA
c1a40e9matches the reviewed commit.
Finding (non-blocking)
- The new unit tests are not run by any Makefile target or by
.github/workflows/docs.yml. See the inline comment ondocs/README.md.
Not verified
npm cifailed in this sandbox on a self-signed TLS certificate, so the Astro build and the new Playwright specs were not run. CI should cover them.- The pre-fetched patch shows the destination regex as
[\^@-\u0020...], but the committed file has[\u0000-\u0020...]. This review uses the committed file.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~1 AIC · ⊞ 4.3K
| This enhancement applies to built static pages, not the dev server. Without | ||
| JavaScript, the original meta refresh still redirects but loses the incoming | ||
| fragment. Run the rewrite unit tests from this directory with | ||
| `node --test src/lib/redirect-fragments.test.js`. |
There was a problem hiding this comment.
The documented test command node --test src/lib/redirect-fragments.test.js is not run by any Makefile target or by .github/workflows/docs.yml (which only runs npm ci --legacy-peer-deps and npm run build). The Playwright specs only run through the webServer in playwright.config.ts. As committed, a regression in redirect-fragments.js would not fail CI. Please add a test-docs-redirect-fragments target (for example, next to test-docs-remark in the Makefile) and call it from the docs workflow. @copilot please address this.
There was a problem hiding this comment.
Added make test-docs-redirect-fragments, wired it into the docs workflow, and updated the README command to use the target from the repository root. Committed as b385ffd.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "c1a40e9968b67704a0f97de0a127993da5653deb",
"kind": "requested",
"schema_version": "1",
"state": "afc4b7fefe15b1eef9bd3e4eaca53734c3d6d981c90f461be2e02ae7033a7540",
"work": [
"3f0ea9e12743365da0319f80a15f3a6f15b4371050e3bc1ba85bebb6dadb9932",
"51e2287c3d1ee41b7e13769862add61dcd292a623cf943abc5968c984e246bcf",
"946ec7592559409044f53598beeb2a0a174acbc023a17990d34f5542ae4dea45"
],
"workflow": "pr-sous-chef"
}
|
…-losing-fragment Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
|
🎉 This pull request is included in a new release. Release: |

Astro’s static meta-refresh redirects discard URL fragments, breaking section bookmarks on moved pages.
Expected navigation: