mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
fix #3328
This commit is contained in:
parent
4b70553263
commit
c7e8b65b6c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user