/**
* Provides quick & simple way to verify if some
* string is valid URL
*
* @param <string> URL to verify
* @returns <boolean> Returns true if passed string
* is valid URL, false otherwise
*/
function validateUrl (url) {
try {
new URL(url)
} catch (error) {
return false
}
return true
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter