3 ms·
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:'].incl
by jfhr 3y 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 https://caniuse.com/url
- keepamovin 3y agoJavaScript elegance is always welcome!