Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
jfhr
· 3y ago · 0 comments
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
Comments
[–]
keepamovin
3y ago
JavaScript elegance is always welcome!