Last active
October 15, 2018 16:56
-
-
Save msteckyefantis/0890bcadb96406da4907275da13e3d77 to your computer and use it in GitHub Desktop.
getIfValueIsUrl
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
function getIfValueIsUrl( value ) { | |
const urlRegex = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi; | |
const valueIsUrl = !!value.match( urlRegex ); | |
return valueIsUrl; | |
} | |
// inspired by https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: this code has not been thoroughly tested