File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -729,8 +729,9 @@ impl Url {
729729 /// # run().unwrap();
730730 /// ```
731731 pub fn username ( & self ) -> & str {
732- if self . has_authority ( ) {
733- self . slice ( self . scheme_end + ( "://" . len ( ) as u32 ) ..self . username_end )
732+ let scheme_separator_len = "://" . len ( ) as u32 ;
733+ if self . has_authority ( ) && self . username_end > self . scheme_end + scheme_separator_len {
734+ self . slice ( self . scheme_end + scheme_separator_len..self . username_end )
734735 } else {
735736 ""
736737 }
Original file line number Diff line number Diff line change @@ -665,3 +665,9 @@ fn test_set_scheme_to_file_with_host() {
665665 assert_eq ! ( url. to_string( ) , "http://localhost:6767/foo/bar" ) ;
666666 assert_eq ! ( result, Err ( ( ) ) ) ;
667667}
668+
669+ #[ test]
670+ fn no_panic ( ) {
671+ let mut url = Url :: parse ( "arhttpsps:/.//eom/dae.com/\\ \\ t\\ :" ) . unwrap ( ) ;
672+ url:: quirks:: set_hostname ( & mut url, "//eom/datcom/\\ \\ t\\ ://eom/data.cs" ) . unwrap ( ) ;
673+ }
You can’t perform that action at this time.
0 commit comments