How can I check if an url is made with an ip address instead of a domain name?
For example:
http://www.yeouuuuu.com/bla
https://www.bbc.co.uk/something
http://yeou:[email protected]/
//return true;
http://172.10.10.100/test
//return false; because there is an IP.
ip4 regex:
ipv4 = RegExp('((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|
[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])');
Why not just test of window.location.hostname has any letter?
window.location.hostname.match(/[a-z]/i)
If it has even one letter then it's not an IP address. No?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With