TLDR Web Dev · QUICK LINKS
THE PROBLEM WITH NEW URL(), AND HOW URL.PARSE() FIXES THAT
Summary from the TLDR Web Dev newsletter
The new URL() constructor in JavaScript throws errors for malformed URLs, requiring additional error handling code, but the new URL.parse() method solves this problem by returning null for invalid URLs.