@@ -83,7 +83,7 @@ fn find_scheme(input: &BStr) -> InputScheme {
83
83
/// For file-paths, we don't expect UTF8 encoding either.
84
84
pub fn parse ( input : & BStr ) -> Result < crate :: Url , Error > {
85
85
match find_scheme ( input) {
86
- InputScheme :: Local => parse_local ( input, false ) ,
86
+ InputScheme :: Local => parse_local ( input) ,
87
87
InputScheme :: Url { protocol_end } if input[ ..protocol_end] . eq_ignore_ascii_case ( b"file" ) => {
88
88
parse_file_url ( input, protocol_end)
89
89
}
@@ -172,10 +172,14 @@ fn parse_file_url(input: &BStr, protocol_colon: usize) -> Result<crate::Url, Err
172
172
} ) ;
173
173
}
174
174
175
- parse_local ( url. path ( ) . into ( ) , true )
175
+ Ok ( crate :: Url {
176
+ serialize_alternative_form : false ,
177
+ host : url. host_str ( ) . map ( Into :: into) ,
178
+ ..parse_local ( url. path ( ) . into ( ) ) ?
179
+ } )
176
180
}
177
181
178
- fn parse_local ( input : & BStr , was_in_url_format : bool ) -> Result < crate :: Url , Error > {
182
+ fn parse_local ( input : & BStr ) -> Result < crate :: Url , Error > {
179
183
if input. is_empty ( ) {
180
184
return Err ( Error :: MissingRepositoryPath {
181
185
url : input. to_owned ( ) ,
@@ -184,7 +188,7 @@ fn parse_local(input: &BStr, was_in_url_format: bool) -> Result<crate::Url, Erro
184
188
}
185
189
186
190
Ok ( crate :: Url {
187
- serialize_alternative_form : !was_in_url_format ,
191
+ serialize_alternative_form : true ,
188
192
scheme : crate :: scheme:: Scheme :: File ,
189
193
password : None ,
190
194
user : None ,
0 commit comments