Validate a URL#358
Conversation
elkarouani
left a comment
There was a problem hiding this comment.
Can you add an explanation of each part of that line of code above the code ?
|
Hey, @rajlomror, thanks for your contribution! However, I have some doubts about this RegExp. Did you write it yourself or copied from somewhere? Why are there some IPs separate? It seems that the use of this is for something else (like figuring if the URL might be on the local network). In general, it's very thicky to write regexps for such general concepts. Similar to an email, the result is either super complex and opinionated or trivial. Maybe it would be better to figure out how to take advantage of build-in URL 😉 |
|
This solution make use of the URL native API : |
One liner JavaScript function to check whether a given value is a valid URL or not.