merge: Add ValidateUrl in String (#856)

* Add ValidateUrl in String

* change regex

* Bug fix
This commit is contained in:
YATIN KATHURIA
2021-12-02 16:23:54 +05:30
committed by GitHub
parent 961f21f97c
commit 6fb649e53d
2 changed files with 27 additions and 0 deletions

13
String/ValidateUrl.js Normal file
View File

@ -0,0 +1,13 @@
/**
* @function ValidateURL
* @description validate the URL.
* @param {String} url - The input URL string
* @return {Boolean}
*/
const validateURL = (url) => {
const URL_PATTERN = /^(https?:\/\/(?:www\.|(?!www))[^\s.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})$/gi
return URL_PATTERN.test(url)
}
export { validateURL }