-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[go_router] Fixes deep links with no path #6447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
auto-submit
merged 13 commits into
flutter:main
from
kforjan:fix-deeplink-root-route-launch
Apr 8, 2024
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3c788b9
Preserve trailing slash for root URLs in canonicalUri
kforjan 7df6b6c
Add tests for preserving trailing slash in root URLs
kforjan 1735d96
Ensure trailing slash for empty paths with query and/or fragment
kforjan d2f8e52
Add and modify tests to include empty path, query and fragment parame…
kforjan f576b70
Update changelog.md and pubspec.yaml
kforjan c37723c
Merge branch 'main' into fix-deeplink-root-route-launch
kforjan cd5f14b
Update changelog for clarification
kforjan e6e44f0
Merge branch 'main' into fix-deeplink-root-route-launch
kforjan 25196df
Merge branch 'main' into fix-deeplink-root-route-launch
kforjan e9b0887
minore fixes, fix parsing placement, add fragment check
kforjan 10d34c8
cover canonical url edge cases
kforjan 80ef126
fix formatting
kforjan f43cc5f
Merge branch 'main' into fix-deeplink-root-route-launch
kforjan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,20 +125,20 @@ String canonicalUri(String loc) { | |
| throw GoException('Location cannot be empty.'); | ||
| } | ||
| String canon = Uri.parse(loc).toString(); | ||
| final Uri uri = Uri.parse(canon); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line128 should be after line 129 I can think of a corner test case |
||
| canon = canon.endsWith('?') ? canon.substring(0, canon.length - 1) : canon; | ||
|
|
||
| // remove trailing slash except for when you shouldn't, e.g. | ||
| // /profile/ => /profile | ||
| // / => / | ||
| // /login?from=/ => login?from=/ | ||
| canon = canon.endsWith('/') && canon != '/' && !canon.contains('?') | ||
| canon = uri.path.endsWith('/') && uri.path != '/' && !uri.hasQuery | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add |
||
| ? canon.substring(0, canon.length - 1) | ||
| : canon; | ||
|
|
||
| // replace '/?', except for first occurrence, from path only | ||
| // /login/?from=/ => /login?from=/ | ||
| // /?from=/ => /?from=/ | ||
| final Uri uri = Uri.parse(canon); | ||
| final int pathStartIndex = uri.host.isNotEmpty | ||
| ? uri.toString().indexOf(uri.host) + uri.host.length | ||
| : uri.hasScheme | ||
|
|
||
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add comma