@@ -522,6 +522,7 @@ const HTTPSRules = {
522522 if ( userpass_present ) blob . newuri . userPass = input_uri . userPass ;
523523 blob . applied_ruleset = rs [ i ] ;
524524 callback ( blob ) ;
525+ return
525526 }
526527 if ( uri . scheme == "https" && alist ) {
527528 // we didn't rewrite but the rule applies to this domain and the
@@ -531,6 +532,7 @@ const HTTPSRules = {
531532 }
532533 }
533534 callback ( null ) ;
535+ return ;
534536 } ) ;
535537 } ,
536538
@@ -605,26 +607,25 @@ const HTTPSRules = {
605607 rulesetsByTargets : function ( targets , callback ) {
606608 var output = [ ] ;
607609 var foundIds = [ ] ;
610+ var neededIds = [ ] ;
608611 var that = this ;
609612 targets . forEach ( function ( target ) {
610- var rulesetIds = that . targets [ target ] ;
611-
612- if ( rulesetIds ) {
613- for ( var i = 0 ; i < rulesetIds . length ; i ++ ) {
614- var id = rulesetIds [ i ] ;
615- if ( ! that . rulesetsByID [ id ] ) {
616- that . loadRulesetById ( id ) ;
617- }
618- if ( that . rulesetsByID [ id ] ) {
619- foundIds . push ( id ) ;
620- output . push ( that . rulesetsByID [ id ] ) ;
621- }
613+ var rulesetIds = that . targets [ target ] || [ ] ;
614+ rulesetIds . forEach ( function ( id ) {
615+ foundIds . push ( id ) ;
616+ if ( ! that . rulesetsByID [ id ] ) {
617+ neededIds . push ( id ) ;
618+ } else {
619+ output . push ( that . rulesetsByID [ id ] ) ;
622620 }
623- } else {
624- that . log ( DBUG , "For target " + target + ", found no ids in DB" ) ;
625- }
621+ } ) ;
622+ } ) ;
623+
624+ neededIds . forEach ( function ( id ) {
625+ that . loadRulesetById ( id ) ;
626+ output . push ( that . rulesetsByID [ id ] ) ;
626627 } ) ;
627- that . log ( DBUG , "For targets " + targets . join ( ' ' ) + ", found ids " + foundIds . join ( ',' ) ) ;
628+ that . log ( WARN , "For targets " + targets . join ( ' ' ) + ", found ids " + foundIds . join ( ',' ) ) ;
628629 callback ( output ) ;
629630 } ,
630631
0 commit comments