Parsing of URLs on the client side has been a common practice for two decades. The early days included using illegible regular expressions but the JavaScript specification eventually evolved into a new URL method of parsing URLs. While URL is incredibly useful when a valid URL is provided, an invalid string will throw an error — yikes! A new method, URL.canParse, will soon be available to validate
![URL.canParse](https://cdn-ak-scissors.b.st-hatena.com/image/square/9993c9cdb0a517bc9f01c87e168851edb677bade/height=288;version=1;width=512/https%3A%2F%2Fdavidwalsh.name%2Fwp-content%2Fthemes%2Fpunky%2Fimages%2Flogo.png)