MCPcopy Index your code
hub / github.com/NobyDa/Script / shortenDomain

Function shortenDomain

Rule-Storage/Rule-Storage.js:138–150  ·  view source on GitHub ↗
(host_name, eTLD_list)

Source from the content-addressed store, hash-verified

136Basic logic: www.abc.com -> .abc.com
137*/
138function 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
152function argsList(data) {
153 return Array.from(

Callers 1

Rule-Storage.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected