Live data from Hacker News

Parsing URLs in Python

tkte.ch

61–70 of 99 posts

Re: Parsing URLs in Python

#62
post #58

Honestly to hell with the WHATWG's weird pseudo-standard. Backslashes? Five forward slashes? No one is sending those URLs around, and if they are, they should fix it. The only thing that needs to deal with that kind of malformed URL is the browser's address bar. If browsers want to do fixups on broken URLs at that point, they should feel free to, but it shouldn't pollute an entire spec. (It's not even a real standard…

It's always been extremely funny to me how arguments like this and from the curl author go. "Yes, I had to change curl away from strictly accepting two slashes, for web compatibility. But `while(slash) { advance_parser() }`? That's completely unreasonable! `while(slash && ++i As for your claim about living standards, I'd encourage you to read https://whatwg.org/faq#living-standard

Re: Parsing URLs in Python

#63

Okay so some googling found me that the "xn--" means the rest of the hostname will be unicode, but why does é become -fsa in www.xn--googl-fsa.com. Google failed on the second part.

In case anyone else is confused as to why the domain in the example provided needs to be unicode (compared to the filename which is obvious): it's because the hyphen is the shorter '‑' char, which is extended ASCII 226 not the standard '-' (which would be ASCII 45).

Re: Parsing URLs in Python

#64
post #55

Earlier quoted context omitted.

It is mindboggling to me how often developers create project names without even trying to search for precedent names in their own domain/industry . Calling this Ada is just ridiculous.

yes but they think it's punny/funny/clever

It's usually a poor reason. Calling the GNU Image Manipulation Program "GIMP" was kinda funny and punny, and maybe humble, but not wise.

Inkscape or Krita have less poignant, but more reasonable name. (But yes, such an approach removes some of the teenage fun from doing a project.)

Re: Parsing URLs in Python

#66
post #2

[flagged]

> Parsing urls is not difficult at all I’d like to have 100 developers each write a url parser, and see how many bugs per implementation we can find. I’d guess an average in the double-digits

I did write a URL parser (including converting relative URLs into absolute) in C (I also wrote a simple HTTP client, and other protocols). However, it is only intended for use with a limited set of URI schemes (including "hashed" and "jar", both of which are unusual in the way they are handled).

(See the function called "scogem_parse_url" in the https://raw.githubusercontent.com/zzo38/scorpion/trunk/scoge... file.)

Now, we can find bug in that one, and then if other people mention theirs too, and find bug in other one, then we can see how accurate your guess is.

However, there are other considerations. For one thing, WHATWG is not the only specification of the working of URLs, so not everyone will comply anyways. And, some features might be necessary or not necessary in specific applications.

Re: Parsing URLs in Python

#67
No mention of prior art? The Hyperlink library has stated correctness as its goal for a long time: https://pypi.org/project/hyperlink

Of course there is always room for new projects, but it still feels weird to act as if this is the first time anybody has ever tried this. It seems like a lot of people are under this same mistaken impression, at least according to the sample of HN users who commented in this thread.

Re: Parsing URLs in Python

#68
post #3

This is intriguing to me for the performance and correctness reasons, but also if it makes the result more dev friendly than the urllib.parse tiple-ish-object result thing.

I posted this elsewhere in the thread, but there absolutely is prior art here. Check out Yarl (urllib.parse wrapper with the nicer interface) and Hyperlink (green field, immutable OO style, focus on correctness). Both on PyPI for many years now.

Re: Parsing URLs in Python

#69

The Ada programming language is cursed with overlapping acronyms. GPS, ADA, SPARK, AWS. Seems it just got a little bit worse.

> Ada is a WHATWG-compliant and fast URL parser written in modern C++ Why would you do that, Daniel?

Ada developer here, Ada is the name of my daughter, and this project is my gift to her, to remember me.

Re: Parsing URLs in Python

#70

The Ada programming language is cursed with overlapping acronyms. GPS, ADA, SPARK, AWS. Seems it just got a little bit worse.

It is mindboggling to me how often developers create project names without even trying to search for precedent names in their own domain/industry . Calling this Ada is just ridiculous.

Ada developer here. Ada URL parser is named after my daughter Ada. We chose this name in particular as a reference to Ada Lovelace.
Post reply on HN