Repository navigation
fix: resolve_route prevent dropping a trailing slash of id - #14294
Merged
Rich-Harris merged 1 commit intoAug 30, 2025
Merged
Conversation
🦋 Changeset detectedLatest commit: 18a1a60 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
yuki0418
commented
Aug 22, 2025
| @@ -240,6 +240,8 @@ const basic_param_pattern = /\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g; | |||
| */ | |||
| export function resolve_route(id, params) { | |||
Contributor
Author
There was a problem hiding this comment.
Should I handle the trailing slash in resolve() function instead of inside of this function?
yuki0418
force-pushed
the
fix-resolve-route-traling-slash
branch
from
August 22, 2025 08:27
18a1a60 to
646f879
Compare
Merged
teemingc
added a commit
that referenced
this pull request
Nov 18, 2026
…17808) Fixes #17805 Since [#15458](#15458), `resolve()` accepts route IDs followed by a query string or fragment. That type-only change assumed the runtime already passed suffixes through correctly, but `resolve_route` treated the entire input as route segments. A final `(group)` therefore stopped matching the group predicate and remained in the destination, producing a 404. Other suffix contents could also undergo segment filtering, parameter replacement or escape expansion. Separate the suffix at the first literal `?` or `#` in the shared resolver, resolve only the route portion, and append the suffix unchanged. Move the existing missing-params guard and parameter defaulting there as well, so brackets inside query strings or fragments do not trigger route-parameter diagnostics. Diagnostics still retain the original input ID. This preserves the group-free segment contract used by route parsing and type generation from [#14050](#14050), and the single-pass parameter/escape expansion from [#16570](#16570). Explicit trailing-slash preservation from [#14294](#14294) now inspects only the route portion, with normalized roots retaining a single slash. Widening the group regex instead would discard the suffix along with the group and leave the other suffix transformations unresolved. Both client and server resolution use this boundary without changing base-path, request-relative or hash-router prefixing. Literal pathname inputs still bypass route-ID processing; build-time callers continue supplying their parameter objects. - [Minimal SvelteLab reproduction](https://www.sveltelab.dev/#code=N4IgzgTgxiBcoBMCWECmUAuB7CBPOoAhgA7EB0AFhgLYA2BIA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AN3rAEbgTc9a3zd1AFLVgxADTSxC7WEB3do%2BnLchBeIJbBZJiqAiH40DKF8AIgg%2Bdhf2sERLgUCwCBoFx1EaQxwJw2Almcd5UCYZTcnAAAAozFQQLT9OM5ZaOctLT6CqszDaGQABWZGcAhorIUSUqwCAqY9gYF75AgtpwNIBhMaQJo9FwCsGA0iLEwRooQAA8thnqcCbBJ62MBhophmAGASzmubcXIOy0MY%2BBUQfSAA2n70B22bIApNq8tIIrgoGAAusoUtPpmUCnGOqDK6r6tIeKJPa7ryh4QY6axwYgIBAMADsQQAAwAKx2-XKdwmAHvNyAXdkOPQwgPb8kGMCSBJDpsch6gM8NyApqoKPykID4yzTwPfs875Xv5vJ6%2B6qPacyJfB-nynzw%2BPTV9tDIj-P3feHr8ClSpGkL-rh-ikdIBgB7h1niAXUE5UBSCjLwKAqRT56y-inAW0lUAqzCFYEgIYAiED8FgUeQQJ4T37vfAwaC8aYMBKPAAzGQAYpDP5fwoegzB18Ai4h8NoFovwtRb1NgYduZB6FTzXiwa8AeNR49zID3YRAAmMhKCZiSEDMfbCo8ABsJDaFKIkdfIhIiyAABZQHyVPA%2BDGqdX5kAzlnIUBMNbVy1mhHihFvRfGwoOCS9FKH8MwdgrxEA8EENkq0Xi15%2BLoMBOJRgtFpB0T8f8ahbQwjXzCW4vixEKjME4KgAAwjbTOsT4l0XSZxc8l4%2BI5PwScT4qBckFKKdoX8yDpBcJ4Z7AkcdoltFaR4nBg4CSBJDJZDyedODsk8mraWQA) <!-- svelte-triage-bot:feedback-baseline:d243d66890c122c246950c28f26c1dc952615c26 --> --------- Co-authored-by: svelte-triage-bot <[email protected]> Co-authored-by: Tee Ming <[email protected]>
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.
Issue #14047
Previous PR was #14065, but it was actually just support a trailing slash for type Pathname, not solving the issue.
Apologize about that I misunderstood the issue.
Problem was
resolve() from @app/pathsdrops trailing slash (technicallyresolve_route()inresolve()does).For example
resolve('/hoge/huga/')returns string of/hoge/hugaChange to keep the trailing slash if
idhas the trailing slash.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits