Add goUp options to pop URL anchor/fragment/hash & query string
#4718
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
goUpmanipulates the URL, using aURLobject to parse/get/set its components where possible.Adds 2 count-compatible Boolean options to
goUp:popAnchorremoves the anchor/hash/fragment from the URL.example.com/a?b=c#d→example.com/a?b=c.popQueryremoves 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 goUpexample.com/a/b?c=d#e→example.com/a→example.commap gu goUp popAnchorexample.com/a/b?c=d#e→example.com/a/b?c=d→example.com/a→example.commap gu goUp popQueryexample.com/a/b?c=d#e→example.com/a/b→example.com/a→example.commap gu goUp popAnchor popQueryexample.com/a/b?c=d#e→example.com/a/b?c=d→example.com/a/b→example.com/a→example.comSubdomains
#3763 also suggests popping subdomains, but it's unclear how/if port numbers should be manipulated when navigating up a subdomain. e.g., should
goUpfromowo.example.com:1337navigate 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🤔.