@@ -154,20 +154,11 @@ RuleSets.prototype = {
154154 this . targets [ host ] . push ( rule_set ) ;
155155 }
156156 } ,
157-
158- setInsert : function ( intoList , fromList ) {
159- // Insert any elements from fromList into intoList, if they are not
160- // already there. fromList may be null.
161- if ( ! fromList ) return ;
162- for ( var i = 0 ; i < fromList . length ; i ++ )
163- if ( intoList . indexOf ( fromList [ i ] ) == - 1 )
164- intoList . push ( fromList [ i ] ) ;
165- } ,
166157
167158 potentiallyApplicableRulesets : function ( host ) {
168159 // Return a list of rulesets that apply to this host
169160 var i , tmp , t ;
170- var results = this . global_rulesets . slice ( 0 ) ; // copy global_rulesets
161+ var results = this . global_rulesets ;
171162 if ( this . targets [ host ] )
172163 results = results . concat ( this . targets [ host ] ) ;
173164 // replace each portion of the domain with a * in turn
@@ -177,13 +168,15 @@ RuleSets.prototype = {
177168 segmented [ i ] = "*" ;
178169 t = segmented . join ( "." ) ;
179170 segmented [ i ] = tmp ;
180- this . setInsert ( results , this . targets [ t ] ) ;
171+ if ( this . targets [ t ] )
172+ results = results . concat ( this . targets [ t ] ) ;
181173 }
182174 // now eat away from the left, with *, so that for x.y.z.google.com we
183175 // check *.z.google.com and *.google.com (we did *.y.z.google.com above)
184- for ( i = 1 ; i < segmented . length - 2 ; ++ i ) {
176+ for ( i = 1 ; i <= segmented . length - 2 ; ++ i ) {
185177 t = "*." + segmented . slice ( i , segmented . length ) . join ( "." ) ;
186- this . setInsert ( results , this . targets [ t ] ) ;
178+ if ( this . targets [ t ] )
179+ results = results . concat ( this . targets [ t ] ) ;
187180 }
188181 log ( DBUG , "Applicable rules for " + host + ":" ) ;
189182 if ( results . length == 0 )
0 commit comments