I tried to validate url with or without http No matter what i did the function return false. I checked my regex string in this site: http://regexr.com/ And its seen as i expect.
Actually, this question needs a powerful regex
and the following code is not very hard to understand, please see below(ES6):
const isValidUrl = urlString => {
const urlRegex = /^((http(s?)?):\/\/)?([wW]{3}\.)?[a-zA-Z0-9\-.]+\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/g;
const result = urlString.match(urlRegex);
return result !== null;
};