Created
December 18, 2018 15:35
-
-
Save marce1994/2eba093bd5e6a9a01ff80d6b29eaf825 to your computer and use it in GitHub Desktop.
Javascript script... to know if the current windows.location.hostname is an url or an ip
This file contains hidden or 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
//192.168.0.1 -> true // domain.domain.com.ar -> false | |
function isIp(str) { | |
return /^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(str); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment