curl / trurl

a command line tool for URL parsing and manipulation.
https://curl.se/trurl/
Other
3.15k stars 102 forks source link

Query string sort #88

Closed cisene closed 1 year ago

cisene commented 1 year ago

Feature:

Order query string variables according to list: $ trurl "https://example.com?echo=foo&lima=foo&november=foo" -qsl '[november, lima, echo]' would produce https://example.com?november=foo&lima=foo&echo=foo

Sorted ascending or descending: $ trurl "https://example.com?echo=foo&lima=foo&november=foo" -qsa would produce https://example.com?echo=foo&lima=foo&november=foo

$ trurl "https://example.com?echo=foo&lima=foo&november=foo" -qsd would produce https://example.com?novemmber=foo&lima=foo&echo=foo

Background: I do a lot of URL manipulation to de-duplicate Podcast feed links (for PodcastIndex.org), by sorting query string variables or ordering them in a desired fashion, duplicates can be found and removed.

bagder commented 1 year ago

I like this idea to enhance a user's ability to compare URLs using queries.

bagder commented 1 year ago

Thinking more on this. Don't we cover most uses cases with just a single alphabetical sort? I mean, does it really add much usability with the lists thing and reversed alphabetical orders?

bagder commented 1 year ago

In the mean time I merged support for --sort-query to allow users to try it out and see if there are actual remaining use cases for other sort methods that this single sort approach does not satisfy.