@@ -5,7 +5,6 @@ use core::str::FromStr;
55pub struct Url {
66 raw : String ,
77 scheme : String ,
8- cannot_be_a_base : bool ,
98 username : String ,
109 password : Option < String > ,
1110 host : Option < Host > ,
@@ -114,39 +113,19 @@ impl FromStr for Url {
114113
115114impl Url {
116115 pub fn parse ( input : & str ) -> Result < Url , ParseError > {
117- let cannot_be_a_base = false ;
118116 let ( rest, scheme) = parse_scheme ( input) ?;
119117 let ( _rest, host, port, path, query, fragment) =
120118 if let Some ( rest) = rest. strip_prefix ( "://" ) {
121119 let ( rest, host) = parse_host ( rest) ?;
122120 let ( rest, port) = parse_port ( rest) . unwrap_or ( ( rest, None ) ) ;
123121 let ( path, query, fragment) = parse_path_query_fragment ( rest) ;
124-
125- let is_empty_host = matches ! ( & host, Host :: Domain ( s) if s. is_empty( ) ) ;
126- if is_empty_host && matches ! ( scheme. as_str( ) , "file" | "blob" ) {
127- let after_colon = & input[ scheme. len ( ) + 1 ..] ;
128- let ( path, query, fragment) = parse_path_query_fragment ( after_colon) ;
129- ( rest, None , None , path, query, fragment)
130- } else {
131- ( rest, Some ( host) , port, path, query, fragment)
132- }
133- } else if let Some ( rest) = rest. strip_prefix ( ":" ) {
134- let ( path, query, fragment) = parse_path_query_fragment ( rest) ;
135- ( rest, None , None , path, query, fragment)
122+ ( rest, Some ( host) , port, path, query, fragment)
136123 } else {
137124 return Err ( ParseError :: InvalidFormat ) ;
138125 } ;
139126
140127 let host = match host {
141- Some ( ref h) if h. is_empty ( ) =>
142- if matches ! ( scheme. as_str( ) , "file" | "blob" ) {
143- None
144- } else {
145- return Err ( ParseError :: EmptyHost ) ;
146- } ,
147- None if !matches ! ( scheme. as_str( ) , "file" | "blob" ) => {
148- return Err ( ParseError :: EmptyHost ) ;
149- }
128+ Some ( ref h) if h. is_empty ( ) => return Err ( ParseError :: EmptyHost ) ,
150129 _ => host,
151130 } ;
152131
@@ -157,7 +136,6 @@ impl Url {
157136 let mut url = Url {
158137 raw : String :: new ( ) ,
159138 scheme,
160- cannot_be_a_base,
161139 username,
162140 password,
163141 host,
0 commit comments