module.exports = opts => { opts = opts || {}; const tlds = opts.tlds ? opts.tlds.join('|') : 'a-z\\u00a1-\\uffff'; const protocol = '(?:(?:[a-z]+:)?//)'; const auth = '(?:\\S+(?::\\S*)?@)?'; const ip = ipRegex.v4().source; const host = '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)'; const domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*'; const tld = '(?:\\.(?:[' + tlds + ']{2,}))'; const port = '(?::\\d{2,5})?'; const path = '(?:[/?#][^\\s"]*)?'; const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`; return opts.exact ? new RegExp(`(?:^${regex}$)`, 'i') : new RegExp(regex, 'ig'); };
module.exports = function (opts) { opts = opts || {}; var protocol = '(?:(?:[a-z]+:)?//)'; var auth = '(?:\\S+(?::\\S*)?@)?'; var ip = ipRegex.v4().source; var host = '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)'; var domain = '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*'; var tld = '(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?'; var port = '(?::\\d{2,5})?'; var path = '(?:[/?#][^\\s"]*)?'; var regex = [ '(?:' + protocol + '|www\\.)' + auth, '(?:localhost|' + ip + '|' + host + domain + tld + ')', port, path ].join(''); return opts.exact ? new RegExp('(?:^' + regex + '$)', 'i') : new RegExp(regex, 'ig'); };
}, (originalValues, want) => { if(want !== 'false') return originalValues; // Init let value, ipRegex = require('ip-regex'), values = originalValues; for(value in values) { // Get server infos let serverInfo = values[value]; // If the IP is not an IPv4 then delete it if(!ipRegex.v4().test(serverInfo[defines.RANDOMDNS_RESOLVER_ADDRESS])) { filtersFormulaDebug('Deleted ' + serverInfo[defines.RANDOMDNS_FULLNAME]); delete values[ value ]; } } return values; }
"use strict";var ipRegex=require("ip-regex"),ip=module.exports=function(e){return ipRegex({exact:!0}).test(e)};ip.v4=function(e){return ipRegex.v4({exact:!0}).test(e)},ip.v6=function(e){return ipRegex.v6({exact:!0}).test(e)};
"use strict"; const ipRegex = require("ip-regex"); const v4 = ipRegex.v4().source + "\\/(3[0-2]|[12]?[0-9])"; const v6 = ipRegex.v6().source + "\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])"; const ip = module.exports = opts => opts && opts.exact ? new RegExp(`(?:^${v4}$)|(?:^${v6}$)`) : new RegExp(`(?:${v4})|(?:${v6})`, "g"); ip.v4 = opts => opts && opts.exact ? new RegExp(`^${v4}$`) : new RegExp(v4, "g"); ip.v6 = opts => opts && opts.exact ? new RegExp(`^${v6}$`) : new RegExp(v6, "g");