Skip to content

Instantly share code, notes, and snippets.

@marce1994
Created December 18, 2018 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marce1994/2eba093bd5e6a9a01ff80d6b29eaf825 to your computer and use it in GitHub Desktop.
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
//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