Add goUp
options to pop URL anchor/fragment/hash & query string
#4718
+31
−9
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
This PR,
Changes how
goUp
manipulates the URL, using aURL
object to parse/get/set its components where possible.Adds 2 count-compatible Boolean options to
goUp
:popAnchor
removes the anchor/hash/fragment from the URL.example.com/a?b=c#d
→example.com/a?b=c
.popQuery
removes query params and the anchor from the URL.example.com/a?b=c#d
→example.com/a
.Fixes #3763. Also relevant: #1344.
Usage
map gu goUp
example.com/a/b?c=d#e
→example.com/a
→example.com
map gu goUp popAnchor
example.com/a/b?c=d#e
→example.com/a/b?c=d
→example.com/a
→example.com
map gu goUp popQuery
example.com/a/b?c=d#e
→example.com/a/b
→example.com/a
→example.com
map gu goUp popAnchor popQuery
example.com/a/b?c=d#e
→example.com/a/b?c=d
→example.com/a/b
→example.com/a
→example.com
Subdomains
#3763 also suggests popping subdomains, but it's unclear how/if port numbers should be manipulated when navigating up a subdomain. e.g., should
goUp
fromowo.example.com:1337
navigate to,owo.example.com
(dropped port)?example.com:1337
(dropped subdomain)?example.com
(both dropped)?IMO, there is no correct option here because it depends on what's at the URL, so I think it'd be best to leave the host name as-is. This would also be consistent with
goToRoot
🤔.