News for hackers. Stuff that matters.
Re:In search of the perfect URL validation regex (2010) by axiosgunnar on Saturday September 25, 2021 @03:36PM (#28655648)
How do browsers parse URLs then?
Re:In search of the perfect URL validation regex (2010) by djur on Saturday September 25, 2021 @03:59PM (#28655787)
There's actually a standard for it these days.

https://url.spec.whatwg.org/#url-parsing

Re:In search of the perfect URL validation regex (2010) by wolfgang42 on Saturday September 25, 2021 @05:35PM (#28656399)
Here’s a polyfill for the JS URL() interface which should give you a taste: https://github.com/zloirock/core-js/blob/272ac1b4515c5cfbf34... (I tried finding the one in Firefox but I couldn’t actually work out where it started, this one is much easier to follow)

TLDR: it’s a traditional parser—a big state machine that steps through the URL character by character and tokenizes it into the relevant pieces.