@@ -117,7 +117,7 @@ impl Runner for FirefoxRunner {
117117 . env ( "NO_EM_RESTART" , "1" )
118118 . args ( & self . args [ ..] ) ;
119119
120- if !self . args . iter ( ) . any ( |x| is_profile_arg ( x ) ) {
120+ if !self . args . iter ( ) . any ( |x| check_arg ( x , & [ "profile" , "p" , "profilemanager" ] ) ) {
121121 command. arg ( "-profile" ) . arg ( & self . profile . path ) ;
122122 }
123123 command. stdout ( Stdio :: inherit ( ) )
@@ -177,16 +177,14 @@ fn name_end_char(c: char) -> bool {
177177 c == ' ' || c == '='
178178}
179179
180- /// Check if an argument string affects the Firefox profile
180+ /// Check if an argument string matches a given name
181181///
182182/// Returns a boolean indicating whether a given string
183- /// contains one of the `-P`, `-Profile` or `-ProfileManager`
184- /// arguments, respecting the various platform-specific conventions.
185- pub fn is_profile_arg ( arg : & str ) -> bool {
183+ /// contains an argument of a given names, respecting
184+ /// various platform-specific conventions.
185+ pub fn check_arg ( arg : & str , names : & [ & str ] ) -> bool {
186186 if let Some ( name) = parse_arg_name ( arg) {
187- name. eq_ignore_ascii_case ( "profile" ) ||
188- name. eq_ignore_ascii_case ( "p" ) ||
189- name. eq_ignore_ascii_case ( "profilemanager" )
187+ names. iter ( ) . any ( |x| x. eq_ignore_ascii_case ( name) )
190188 } else {
191189 false
192190 }
@@ -320,7 +318,7 @@ pub mod platform {
320318
321319#[ cfg( test) ]
322320mod tests {
323- use super :: { parse_arg_name, is_profile_arg } ;
321+ use super :: { parse_arg_name, check_arg } ;
324322
325323 fn parse ( arg : & str , name : Option < & str > ) {
326324 let result = parse_arg_name ( arg) ;
@@ -362,15 +360,16 @@ mod tests {
362360 }
363361
364362 #[ test]
365- fn test_is_profile_arg ( ) {
366- assert ! ( is_profile_arg( "--profile" ) ) ;
367- assert ! ( is_profile_arg( "-p" ) ) ;
368- assert ! ( is_profile_arg( "-PROFILEMANAGER" ) ) ;
369- assert ! ( is_profile_arg( "-ProfileMANAGER" ) ) ;
370- assert ! ( !is_profile_arg( "-- profile" ) ) ;
371- assert ! ( !is_profile_arg( "-profiled" ) ) ;
372- assert ! ( !is_profile_arg( "-p1" ) ) ;
373- assert ! ( is_profile_arg( "-p test" ) ) ;
374- assert ! ( is_profile_arg( "-profile /foo" ) ) ;
363+ fn test_check_arg ( ) {
364+ assert ! ( check_arg( "--profile" , & [ "profile" ] ) ) ;
365+ assert ! ( check_arg( "-p" , & [ "p" ] ) ) ;
366+ assert ! ( check_arg( "-PROFILEMANAGER" , & [ "profilemanager" ] ) ) ;
367+ assert ! ( check_arg( "-ProfileMANAGER" , & [ "profilemanager" ] ) ) ;
368+ assert ! ( !check_arg( "-- profile" , & [ "profile" ] ) ) ;
369+ assert ! ( !check_arg( "-profiled" , & [ "profile" ] ) ) ;
370+ assert ! ( !check_arg( "-p1" , & [ "p" ] ) ) ;
371+ assert ! ( check_arg( "-p test" , & [ "p" ] ) ) ;
372+ assert ! ( check_arg( "-profile /foo" , & [ "profile" ] ) ) ;
373+ assert ! ( check_arg( "-profile" , & [ "p" , "profile" ] ) ) ;
375374 }
376375}
0 commit comments