News Score: Score the News, Sort the News, Rewrite the Headlines

The problem with new URL(), and how URL.parse() fixes that | Kilian Valkhof

The problem with new URL(), and how URL.parse() fixes thatAs someone building a browser I need to parse a lot of URLs. Partially to validate them, but also to normalize them or get specific parts out of the URL. The URL API in browsers lets you do that, but it’s ergonomics aren’t ideal.The problem with new URL()The “new” in front of new URL() indicates that it’s used as a constructor: calling it creates a new URL instance for you. When you give it a malformed URL however, one that it can’t parse...

Read more at kilianvalkhof.com

© News Score  score the news, sort the news, rewrite the headlines