@@ -540,7 +540,6 @@ impl<'a> Parser<'a> {
540540 self . parse_path ( SchemeType :: File , & mut has_host, path_start, remaining)
541541 } ;
542542
543- trim_path ( & mut self . serialization , host_end as usize ) ;
544543 // For file URLs that have a host and whose path starts
545544 // with the windows drive letter we just remove the host.
546545 if !has_host {
@@ -598,8 +597,6 @@ impl<'a> Parser<'a> {
598597
599598 let host_start = host_start as u32 ;
600599
601- trim_path ( & mut self . serialization , host_end) ;
602-
603600 let ( query_start, fragment_start) =
604601 self . parse_query_and_fragment ( scheme_type, scheme_end, remaining) ?;
605602
@@ -1287,6 +1284,15 @@ impl<'a> Parser<'a> {
12871284 break ;
12881285 }
12891286 }
1287+ if scheme_type. is_file ( ) {
1288+ // while url’s path’s size is greater than 1
1289+ // and url’s path[0] is the empty string,
1290+ // validation error, remove the first item from url’s path.
1291+ //FIXME: log violation
1292+ let path = self . serialization . split_off ( path_start) ;
1293+ self . serialization . push ( '/' ) ;
1294+ self . serialization . push_str ( & path. trim_start_matches ( "/" ) ) ;
1295+ }
12901296 input
12911297 }
12921298
@@ -1495,18 +1501,6 @@ impl<'a> Parser<'a> {
14951501 }
14961502}
14971503
1498- // Trim path start forward slashes when no authority is present
1499- // https://github.com/whatwg/url/issues/232
1500- pub fn trim_path ( serialization : & mut String , path_start : usize ) {
1501- let path = serialization. split_off ( path_start) ;
1502- if path. starts_with ( "/" ) {
1503- serialization. push ( '/' ) ;
1504- serialization. push_str ( & path. trim_start_matches ( "/" ) ) ;
1505- } else {
1506- serialization. push_str ( & path) ;
1507- }
1508- }
1509-
15101504#[ inline]
15111505fn is_ascii_hex_digit ( c : char ) -> bool {
15121506 matches ! ( c, 'a' ..='f' | 'A' ..='F' | '0' ..='9' )
0 commit comments