Created
October 19, 2020 15:31
-
-
Save agodin3z/9ec27b795f20cc99756406a22efea8a8 to your computer and use it in GitHub Desktop.
Check if the string is a valid URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isValidUrl = (url) => { | |
const regex = new RegExp(/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi); | |
return url.match(regex); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment