Last active
December 10, 2020 14:41
-
-
Save oiljin/7436b3e1076adb9ee166 to your computer and use it in GitHub Desktop.
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 isUrl(url) { | |
var re = /^(http\:\/\/|https\:\/\/)?([a-z0-9][a-z0-9\-]*\.)+[a-z0-9][a-z0-9\-]*[a-z0-9]$/i; | |
return re.test(url); | |
} | |
console.log(isUrl('12domain.ru')); // true | |
console.log(isUrl('www.domain.com')); // true | |
console.log(isUrl('http://domain.com')); // true | |
console.log(isUrl('https://domain.com')); // true | |
console.log(isUrl('-12domain.ru')); // false | |
console.log(isUrl('www.domain.c')); // false | |
console.log(isUrl('http://domain.com-')); // false | |
console.log(isUrl('https:/domain.com')); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment