Live data from Hacker News

New tool from curl creator – trurl – for URL parsing and manipulation

daniel.haxx.se

21–30 of 40 posts

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#22

Pardone my ignorance, serious question: Why is this a big deal? I'm probably underestimting the work needed, but it doesn't look like a hard thing to write. What am I missing?

Over the years, curl itself has had 9 CVEs relating to handling URLs [0] so this is most definitely not a trivial piece of code to write. The basic case is easy, yes. Getting everything in the spec right and then some is hard. [0] https://curl.se/docs/security.html

is it somehow better than the stuff available in mainstream languages (go net/url, Python yarl, etc)?

Or is it just that this is focused on command-line usage

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#23

Pardone my ignorance, serious question: Why is this a big deal? I'm probably underestimting the work needed, but it doesn't look like a hard thing to write. What am I missing?

I will be using this at work tomorrow. I currently parse out this stuff using a flaky little bit of python I cooked up myself and it gives me no end of grief when scaled. So many awful edge cases. The author wrote curl, so I know it's going to do what it says it does well. That's why it's getting love. It's a rock star dev putting out open source code many of us will absolutely be using regularly. Way classier than y…

Why not use urllib.parse?

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#24

Earlier quoted context omitted.

I will be using this at work tomorrow. I currently parse out this stuff using a flaky little bit of python I cooked up myself and it gives me no end of grief when scaled. So many awful edge cases. The author wrote curl, so I know it's going to do what it says it does well. That's why it's getting love. It's a rock star dev putting out open source code many of us will absolutely be using regularly. Way classier than y…

Why not use urllib.parse?

Hah, I may well do! I think the other thing here is me not realising I needed something till I saw it :-)

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#26
post #17
post #13

Earlier quoted context omitted.

Given what it does, and to avoid confusion with perl, "transform url" seems more reasonable. Though I probably would have gone with "turl" so it's easier to pronounce.

It seems like a nod to the “tr” command.

Yup, I guessed the same, and indeed it explicitly states so in the blog post linked by another commenter.

> trurl is a tool in a similar spirit of tr but for URLs. Here, tr stands for translate or transpose.

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#27
post #2

Might be more useful to link to the blog post: https://daniel.haxx.se/blog/2023/04/03/introducing-trurl/

Previously posted:

https://news.ycombinator.com/item?id=35419573 - 22 points, 2 comments

https://news.ycombinator.com/item?id=35426050 - 5 points, 0 comments

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#28

Pretty dang cool, but I might have missed a feature: can trurl do multiple manipulations on a single url, as opposed to a single manipulation on multiple urls (which the blog post says is supported)? For example, you want to apply a sequence of predefined normalization steps, such as removing the user part, converting http to https, etc etc. You put these steps in a file and then invoke trurl with that file and point…

I think it can do what you're suggesting, if I'm understanding correctly:

> $ trurl --url https://example.com --set path=/abc/123 --set scheme=ftp --set host=foo.bar

> $ ftp://foo.bar/abc/123

Re: New tool from curl creator – trurl – for URL parsing and manipulation

#30
post #11

that an ... interesting ... decsion to put inputs before -- and commands/options after -- Most of the tools assume opposite default (like xargs for example). Sure, you can specify a different order but why make life harder for no reason?

Usage: " PROGNAME " [options] [URL]

But you can put options wherever you want, they are identified by the leading '-' char.

Post reply on HN