I need a way to determine if the input string is an IP address, and return true if it is.
My current function using ipaddr.js library looks like this
import * as ipaddr from 'ipaddr.js';
function isIpaddress(ip) {
return ipaddr.isValid(ip);
}
Surprisingly, this method returns true even for any number passed into it. As a first-time user of ipaddr.js, I expected .isValid to perform all necessary checks automatically.
If anyone can offer assistance or explanation on why this behavior occurs, I would greatly appreciate it. Thank you.