Hacker News new | ask | show | jobs
by jfhr 957 days ago
Unless you need to support ancient browsers [1], I'd go the easy way and leave the URL parsing to the browser, e.g. `['http:', 'https:', 'mailto:', 'tel:'].includes(new URL(value, location.origin).protocol)`

[1] https://caniuse.com/url

1 comments

JavaScript elegance is always welcome!