fix: stop stripping trailing slashes in yew-router#4110
Merged
Madoshakalaka merged 3 commits intomasterfrom Apr 4, 2026
Merged
fix: stop stripping trailing slashes in yew-router#4110Madoshakalaka merged 3 commits intomasterfrom
Madoshakalaka merged 3 commits intomasterfrom
Conversation
Remove `strip_slash_suffix` from route registration and matching so `/path` and `/path/` are treated as distinct routes. This fixes incorrect relative-path resolution in components served under trailing-slash URLs. BREAKING CHANGE: routes with trailing slashes now only match URLs with trailing slashes and vice versa. Define both variants if you need both forms to work.
Member
Author
|
I have prepared a migration guide and will edit the website at release. |
|
Visit the preview URL for this PR (updated for commit f03475f): https://yew-rs--pr4110-fix-trailing-slash-s-5pw49jvc.web.app (expires Sat, 11 Apr 2026 07:59:29 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
The nested router example now defines a SettingsSlash variant for /settings/ and redirects it to SettingsRoot
shan-shaji
pushed a commit
to shan-shaji/yew
that referenced
this pull request
Apr 19, 2026
* fix: stop stripping trailing slashes in yew-router BREAKING CHANGE: routes with trailing slashes now only match URLs with trailing slashes and vice versa. Define both variants if you need both forms to work. * docs(website): update nested router example for trailing slash semantics The nested router example now defines a SettingsSlash variant for /settings/ and redirects it to SettingsRoot
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.
Description
Stop stripping trailing slashes from route patterns and incoming URLs during matching.
/pathand/path/are now distinct routes, matching standard URL semantics.Previously,
yew-routercalledstrip_slash_suffixon both registered route patterns and incoming pathnames before matching. This made/settingsand/settings/resolve to the same route variant, but the browser resolves relative paths differently for each form (./img.jpgfrom/settingsresolves to/img.jpg; from/settings/resolves to/settings/img.jpg). This caused silent breakage for components that use relative asset paths.With this change:
#[at("/settings/")]only match URLs with trailing slash#[at("/settings")]only match URLs without trailing slash#[at("/")]is unaffectedFixes #4098
Checklist