Skip to content

Commit

Permalink
code review for gorhill#3328
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Dec 8, 2017
1 parent c7e8b65 commit e83ffde
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/js/hntrie.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e83ffde

Please sign in to comment.