Skip to content

Preserve URL fragments through static docs redirects - #78608

Merged
pelikhan merged 4 commits into
mainfrom
copilot/fix-redirects-losing-fragment
Nov 17, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/fix-redirects-losing-fragment

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Redirect handling: Add a post-build integration that inserts fragment-preserving JavaScript before meta refreshes, only when their targets match the configured redirects.
  • Precedence and fallback: Explicit destination fragments win. The original meta refresh remains the no-JavaScript fallback, which still loses incoming fragments.
  • Coverage and documentation: Add HTML rewrite unit tests, built-site browser regressions, and README guidance on supported redirects and limitations.

Expected navigation:

/gh-aw/workshop/#x
→ /gh-aw/guides/workshop/#x

/gh-aw/reference/servicenow-connector/#other
→ /gh-aw/reference/connectors/#servicenow

@pelikhan pelikhan changed the title [WIP] Fix redirects dropping URL fragment in Astro Preserve URL fragments through static docs redirects Nov 17, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 17, 2026 05:09
Copilot AI adaptive review requested due to automatic review settings November 17, 2026 05:09
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)

Comment thread docs/src/lib/redirect-fragments.test.js Outdated

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 c1a40e9 matches 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 on docs/README.md.
Not verified
  • npm ci failed 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

Comment thread docs/README.md Outdated
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`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (docs/src/lib/redirect-fragments.test.js:64): address unresolved feedback - Review comment
  3. Review (docs/README.md:209): address unresolved feedback - Review comment
  4. Fix failing check conclusion (FAILURE): Check run.

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"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 7K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 17, 2026 05:48
…-losing-fragment

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Copilot AI requested a review from gh-aw-bot November 17, 2026 06:06
@pelikhan
pelikhan merged commit 50e5924 into main Nov 17, 2026
93 checks passed
@pelikhan
pelikhan deleted the copilot/fix-redirects-losing-fragment branch November 17, 2026 06:11
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: redirects drop the #fragment of the requested URL

4 participants