@@ -540,7 +540,6 @@ impl<'a> Parser<'a> {
540
540
self . parse_path ( SchemeType :: File , & mut has_host, path_start, remaining)
541
541
} ;
542
542
543
- trim_path ( & mut self . serialization , host_end as usize ) ;
544
543
// For file URLs that have a host and whose path starts
545
544
// with the windows drive letter we just remove the host.
546
545
if !has_host {
@@ -598,8 +597,6 @@ impl<'a> Parser<'a> {
598
597
599
598
let host_start = host_start as u32 ;
600
599
601
- trim_path ( & mut self . serialization , host_end) ;
602
-
603
600
let ( query_start, fragment_start) =
604
601
self . parse_query_and_fragment ( scheme_type, scheme_end, remaining) ?;
605
602
@@ -1287,6 +1284,15 @@ impl<'a> Parser<'a> {
1287
1284
break ;
1288
1285
}
1289
1286
}
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
+ }
1290
1296
input
1291
1297
}
1292
1298
@@ -1495,18 +1501,6 @@ impl<'a> Parser<'a> {
1495
1501
}
1496
1502
}
1497
1503
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
-
1510
1504
#[ inline]
1511
1505
fn is_ascii_hex_digit ( c : char ) -> bool {
1512
1506
matches ! ( c, 'a' ..='f' | 'A' ..='F' | '0' ..='9' )
0 commit comments