File tree 1 file changed +24
-3
lines changed
1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -213,9 +213,8 @@ fn parse_scheme(s: &str) -> Option<usize> {
213
213
214
214
fn parse_authority ( s : & str ) -> usize {
215
215
let i = s. find ( "://" ) . map ( |p| p + 3 ) . unwrap_or ( 0 ) ;
216
- s[ i..] . find ( '/' )
217
- . or_else ( || s[ i..] . find ( '?' ) )
218
- . or_else ( || s[ i..] . find ( '#' ) )
216
+ s[ i..]
217
+ . find ( |ch| ch == '/' || ch == '?' || ch == '#' )
219
218
. map ( |end| end + i)
220
219
. unwrap_or ( s. len ( ) )
221
220
}
@@ -537,6 +536,28 @@ test_parse! {
537
536
port = None ,
538
537
}
539
538
539
+ test_parse ! {
540
+ test_uri_parse_absolute_form_with_empty_path_and_fragment_with_slash,
541
+ "http://127.0.0.1#foo/bar" ,
542
+ scheme = Some ( "http" ) ,
543
+ authority = Some ( "127.0.0.1" ) ,
544
+ path = "/" ,
545
+ query = None ,
546
+ fragment = Some ( "foo/bar" ) ,
547
+ port = None ,
548
+ }
549
+
550
+ test_parse ! {
551
+ test_uri_parse_absolute_form_with_empty_path_and_fragment_with_questionmark,
552
+ "http://127.0.0.1#foo?bar" ,
553
+ scheme = Some ( "http" ) ,
554
+ authority = Some ( "127.0.0.1" ) ,
555
+ path = "/" ,
556
+ query = None ,
557
+ fragment = Some ( "foo?bar" ) ,
558
+ port = None ,
559
+ }
560
+
540
561
#[ test]
541
562
fn test_uri_parse_error ( ) {
542
563
fn err ( s : & str ) {
You can’t perform that action at this time.
0 commit comments