(host_name, rule_list)
| 80 | } |
| 81 | |
| 82 | function evalRules(host_name, rule_list) { |
| 83 | const host_suffix = host_name.split('.').reverse(); |
| 84 | rule_list = typeof rule_list == 'object' ? rule_list : formatRules(rule_list, 1); |
| 85 | for (const i in rule_list) { |
| 86 | if (rule_list[i].startsWith('.') && !rule_list[i].endsWith('.')) { |
| 87 | const rule_host_suffix = rule_list[i].split('.').reverse().filter((v) => v); |
| 88 | if (rule_host_suffix.filter((v, i) => host_suffix[i] === v).length === rule_host_suffix.length) { |
| 89 | return true |
| 90 | } |
| 91 | } else if (rule_list[i].startsWith('.') && rule_list[i].endsWith('.')) { |
| 92 | if (host_name.includes(rule_list[i].slice(1, -1))) { |
| 93 | return true |
| 94 | } |
| 95 | } else if (rule_list[i] === host_name) { |
| 96 | return true |
| 97 | } |
| 98 | } |
| 99 | return false |
| 100 | } |
| 101 | |
| 102 | function formatRules(list, type) { |
| 103 | return (list || '').replace(/\r|\ |(\/\/|#|;).*/g, '').split('\n').map((v) => { |
no test coverage detected