File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,8 @@ impl<'a> Parser<'a> {
398
398
}
399
399
400
400
pub fn parse_scheme < ' i > ( & mut self , mut input : Input < ' i > ) -> Result < Input < ' i > , ( ) > {
401
+ // starts_with will also fail for empty strings
402
+ // so we can skip that comparison for perf
401
403
if !input. starts_with ( ascii_alpha) {
402
404
return Err ( ( ) ) ;
403
405
}
Original file line number Diff line number Diff line change @@ -1031,6 +1031,14 @@ fn test_set_scheme_to_file_with_host() {
1031
1031
assert_eq ! ( result, Err ( ( ) ) ) ;
1032
1032
}
1033
1033
1034
+ #[ test]
1035
+ fn test_set_scheme_empty_err ( ) {
1036
+ let mut url: Url = "http://localhost:6767/foo/bar" . parse ( ) . unwrap ( ) ;
1037
+ let result = url. set_scheme ( "" ) ;
1038
+ assert_eq ! ( url. to_string( ) , "http://localhost:6767/foo/bar" ) ;
1039
+ assert_eq ! ( result, Err ( ( ) ) ) ;
1040
+ }
1041
+
1034
1042
#[ test]
1035
1043
fn no_panic ( ) {
1036
1044
let mut url = Url :: parse ( "arhttpsps:/.//eom/dae.com/\\ \\ t\\ :" ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments