Files
is-a-good-dev/utils/utils.js
T
2022-11-04 16:46:39 +08:00

13 lines
458 B
JavaScript

module.exports.checkIfValidIP = function(str) {
// Check if the IP address is valid
const regexExp = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gi;
return regexExp.test(str);
}
module.exports.checkIfValidFQDN = function(str) {
// Check if the FQDN is valid
const regexExp = /(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)/gi;
return regexExp.test(str);
}