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.

28 lines
474 B

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