Repository navigation
fix(platform-redirect): Keep the anchor when no platform is selected - #20234
Merged
Merged
Conversation
`PlatformLink` points at `/platform-redirect/?next=<encoded path>` when no
platform is active, and `sanitizeNext` returned only `url.pathname`, so the
fragment was dropped from both the redirect and the links on the selection
page. Around 770 `PlatformLink` uses carry an anchor.
The fragment can't simply be appended to the returned path: `page.tsx` feeds
that value into `nodeForPath(...pathname.split('/'))`, so a `#frag` segment
would break doc tree resolution and fall through to "We couldn't find
documentation for this path". `sanitizeNext` now returns the path and the
fragment separately, and only the URL-building sites append the fragment.
Fragments are allowlisted (`/^#[\w.-]+$/`, covering slugs like
`godot_logger.event_mask`) and an unrecognized one is dropped rather than
failing the whole redirect. The existing hardening is untouched: the colon
guard still runs on the whole decoded string before parsing, the origin check
is unchanged, and a fragment is appended only to a doc-tree-resolved URL.
Also adds `platformUrlFor`, which joins the platform URL with the path without
leaving the `//` that made every platform redirect 308 a second time
(`/platforms/python//configuration/options/`).
Drive-by: four `PlatformLink`s had a trailing slash appended after the
fragment by older trailing-slash tooling, so their anchors matched nothing.
The two Flutter ones also pointed through a redirect at an id that no longer
exists, and now go straight to
`/debug-symbols/#when-to-upload-debug-symbols`.
Fixes #20226
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Monitoring services · Rollout details
Mention |
sergical
approved these changes
Oct 26, 2026
Contributor
|
Verified in
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DESCRIBE YOUR PR
Fixes #20226.
When no platform is active,
PlatformLinkpoints at/platform-redirect/?next=<encoded path>.sanitizeNextreturned onlyurl.pathname, so the anchor was dropped from both the redirect and the links on the selection page. Around 770PlatformLinkuses carry an anchor.Reproduced before the fix:
The fragment can't just be appended to the returned path —
page.tsxfeeds that value intonodeForPath(...pathname.split('/')), so a#fragsegment would break doc tree resolution and fall through to "We couldn't find documentation for this path". So the path and the fragment are now returned separately, and only the two URL-building sites append the fragment.sanitizeNextreturns{pathname, hash}; every doc tree lookup keeps usingpathnamealone/^#[\w.-]+$/, which covers slugs likegodot_logger.event_mask); an unrecognized fragment is dropped rather than failing the whole redirectplatformUrlFor, which joins the platform URL with the path without leaving the//that made every platform redirect 308 a second timePlatformLinks had a trailing slash appended after the fragment by older trailing-slash tooling, so their anchors matched nothing. The two Flutter ones also pointed through a redirect at an id that no longer exists, and now go straight to/debug-symbols/#when-to-upload-debug-symbolsSecurity
The existing hardening is deliberately untouched — the colon guard still runs on the whole decoded string before parsing (so
javascript:/data:are still rejected), the origin check is unchanged, and a fragment is only ever appended to a doc-tree-resolved URL, so it can't influence the origin. New tests cover/a/#@example.comand/a/#//example.combeing dropped, plus%2523double-encoding.Verification
utils.spec.ts, up from 16)tsc, eslint and prettier cleanpnpm lint:trailing-slashclean — the current linter is already fragment-aware, so the four fixed anchors don't regressIS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace
YYYY-MM-DDwith the due date. You can update this information later by editing the PR description.SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
🤖 Generated with Claude Code