A cli tool to quickly create and manage nginx server blocks. https://up.js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
420 B

// Parses a string, and returns true if it is an IP Address.
function isIP(str) {
var segments = str
.split('.')
.map(Number);
if (!segments.length === 4) {
return false;
}
for (var segment of segments) {
if (Number.isNaN(segment)) {
return false;
}
if (segment < 1 || segment > 255) {
return false;
}
}
if (segments[3] > 254) {
return false;
}
return true;
}
module.exports = isIP;