code review for #3328

This commit is contained in:
gorhill 2017-12-08 07:07:05 -05:00
parent c7e8b65b6c
commit e83ffde5af
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 1 deletions

View File

@ -188,9 +188,12 @@ HNTrieBuilder.prototype.fromDomainOpt = function(hostnames) {
};
HNTrieBuilder.prototype.fromIterable = function(hostnames) {
var hns = Array.from(hostnames).sort(function(a, b) {
return a.length - b.length;
});
// 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;}) ) {
for ( var hn of hns ) {
this.add(hn);
}
return this;