curl / trurl

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

Add --replace as a command #261

Closed jacobmealey closed 6 months ago

jacobmealey commented 9 months ago

implement --replace as seen in #260 discussion

emanuele6 commented 9 months ago

Instead of adding a replacelist and all this extra code‚ can't this be implemented as just calls to trimadd(); appendadd() in replaceadd()?

jacobmealey commented 9 months ago

I was worried about preserving the order of the other items in the list query list, if we did it with trimadd and appendadd it would always put it at the end of the query list, right? If that's not an issue then I can rework this pr this evening to do it that way because it will simplify things.

bagder commented 6 months ago

Thanks for this work @jacobmealey.

These options are rather specific for query strings, as they are the only components in a URL that is actually a list of value pairs and therefore the only component where replace makes sense as everywhere else you can just set the component to replace it.

Based on this, I don't foresee that these options can be made to support other components than the query. If nobody else can come up with a scenario where that could happen, maybe we could streamline these a little more? For example maybe --replace foo=bar directly instead of --replace query=foo=bar ?

jacobmealey commented 6 months ago

@bagder that makes sense, I will get started on that this weekend. It should be pretty quick so hopefully I'll have a PR by Sunday.

bagder commented 6 months ago

Thanks!