Add advanced normalizePathname option to FetchState#17354
Draft
matthewp wants to merge 2 commits into
Draft
Conversation
🦋 Changeset detectedLatest commit: d25ec4f The changes in this PR will be included in the next version bump. This PR includes changesets to release 396 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
matthewp
marked this pull request as ready for review
July 10, 2026 20:40
matthewp
marked this pull request as draft
July 10, 2026 20:41
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.
Changes
normalizePathnameas a way to customize normalizing (including decoding) the pathname which is used to constructAstro.url,Astro.paramsamong other things.normalizebecause it doesn't just do decoding, it also removing duplicate slashes in the default implementation.Testing
test/units/util/normalize-pathname.test.ts, a dedicated suite for the default normalizer's security behavior: encoded/literal/double-encoded backslash rewriting (%5Cadmin→/admin), duplicate-slash collapse (//admin→/admin), preservation of reserved/double-encoded slashes so they aren't turned into separators (%2F,%252F), decode delegation, and malformed/over-encoded rejection.test/units/fetch/index.test.tscovering the default%25→%decode, a custom no-op preserving%25, verbatim duplicate-slash handling (custom keeps//, default collapses it), route-param derivation from the custom pathname, exposure of the normalizer on state, and the exported default.Docs
FetchStatenormalizePathnameoption docs#14218