| 136 | Basic logic: www.abc.com -> .abc.com |
| 137 | */ |
| 138 | function shortenDomain(host_name, eTLD_list) { |
| 139 | return host_name.split('.').reverse().reduce((t, v, i, c) => { |
| 140 | if (t === host_name || c.length == 2) { return host_name } |
| 141 | if (t.startsWith('.')) { return t } |
| 142 | const host_suffix = v + (t && `.${t}` || ''); |
| 143 | for (const ix in eTLD_list) { |
| 144 | if (eTLD_list[ix] === host_suffix) { |
| 145 | return host_suffix |
| 146 | } |
| 147 | } |
| 148 | return !i && host_name || `.${host_suffix}` |
| 149 | }, '') |
| 150 | } |
| 151 | |
| 152 | function argsList(data) { |
| 153 | return Array.from( |