1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00
This commit is contained in:
gorhill 2017-12-08 00:33:02 -05:00
parent 4b70553263
commit c7e8b65b6c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -184,19 +184,13 @@ HNTrieBuilder.prototype.add = function(hn) {
*/
HNTrieBuilder.prototype.fromDomainOpt = function(hostnames) {
var len = hostnames.length,
beg = 0, end;
while ( beg < len ) {
end = hostnames.indexOf('|', beg);
if ( end === -1 ) { end = len; }
this.add(hostnames.slice(beg, end));
beg = end + 1;
}
return this;
return this.fromIterable(hostnames.split('|'));
};
HNTrieBuilder.prototype.fromIterable = function(hostnames) {
for ( var hn of hostnames ) {
// https://github.com/gorhill/uBlock/issues/3328
// Must sort from shortest to longest.
for ( var hn of hostnames.sort(function(a,b){return a.length-b.length;}) ) {
this.add(hn);
}
return this;