UNPKG

n4s

Version:

typed schema validation version of enforce

94 lines (83 loc) 4.18 kB
const require_merge = require('./merge-Co1t_slP.cjs'); //#region ../../node_modules/validator/es/lib/isFQDN.js var default_fqdn_options = { require_tld: true, allow_underscores: false, allow_trailing_dot: false, allow_numeric_tld: false, allow_wildcard: false, ignore_max_length: false }; function isFQDN(str, options) { require_merge.assertString(str); options = require_merge.merge(options, default_fqdn_options); if (options.allow_trailing_dot && str[str.length - 1] === ".") str = str.substring(0, str.length - 1); if (options.allow_wildcard === true && str.indexOf("*.") === 0) str = str.substring(2); var parts = str.split("."); var tld = parts[parts.length - 1]; if (options.require_tld) { if (parts.length < 2) return false; if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) return false; if (/\s/.test(tld)) return false; } if (!options.allow_numeric_tld && /^\d+$/.test(tld)) return false; return parts.every(function(part) { if (part.length > 63 && !options.ignore_max_length) return false; if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) return false; if (/[\uff01-\uff5e]/.test(part)) return false; if (/^-|-$/.test(part)) return false; if (!options.allow_underscores && /_/.test(part)) return false; return true; }); } //#endregion //#region ../../node_modules/validator/es/lib/isIP.js /** 11.3. Examples The following addresses fe80::1234 (on the 1st link of the node) ff02::5678 (on the 5th link of the node) ff08::9abc (on the 10th organization of the node) would be represented as follows: fe80::1234%1 ff02::5678%5 ff08::9abc%10 (Here we assume a natural translation from a zone index to the <zone_id> part, where the Nth zone of any scope is translated into "N".) If we use interface names as <zone_id>, those addresses could also be represented as follows: fe80::1234%ne0 ff02::5678%pvc1.3 ff08::9abc%interface10 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs to the 5th link, and "interface10" belongs to the 10th organization. * * */ var IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"; var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat); var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$")); var IPv6SegmentFormat = "(?:[0-9a-fA-F]{1,4})"; var IPv6AddressRegExp = /* @__PURE__ */ new RegExp("^(" + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ")(%[0-9a-zA-Z-.:]{1,})?$"); function isIP(str) { var version = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ""; require_merge.assertString(str); version = String(version); if (!version) return isIP(str, 4) || isIP(str, 6); if (version === "4") return IPv4AddressRegExp.test(str); if (version === "6") return IPv6AddressRegExp.test(str); return false; } //#endregion Object.defineProperty(exports, 'isFQDN', { enumerable: true, get: function () { return isFQDN; } }); Object.defineProperty(exports, 'isIP', { enumerable: true, get: function () { return isIP; } }); //# sourceMappingURL=isIP-BBSgBWBl.cjs.map