File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -393,11 +393,11 @@ impl<T> Node<T> {
393393 }
394394
395395 // Similarly, if we are inserting a longer prefix, and there is a route that leads to this
396- // parameter that includes a suffix, we have a prefix-suffix conflicts .
397- if common_remaining [ common_prefix - 1 ] != b'/'
398- && node. suffix_wild_child_in_segment ( )
399- {
400- return Err ( InsertError :: conflict ( & route , remaining , node ) ) ;
396+ // parameter that includes a suffix, we have a prefix-suffix conflict .
397+ if let Some ( i ) = common_prefix . checked_sub ( 1 ) {
398+ if common_remaining [ i ] != b'/' && node. suffix_wild_child_in_segment ( ) {
399+ return Err ( InsertError :: conflict ( & route , remaining , node ) ) ;
400+ }
401401 }
402402 }
403403
Original file line number Diff line number Diff line change @@ -16,10 +16,18 @@ fn conflict(with: &'static str) -> InsertError {
1616 InsertError :: Conflict { with : with. into ( ) }
1717}
1818
19- // https://github.com/ibraheemdev/matchit/issues/84
19+ // Regression test for https://github.com/ibraheemdev/matchit/issues/84.
2020#[ test]
21- fn root_prefix_issue ( ) {
22- InsertTest ( vec ! [ ( "{foo}" , Ok ( ( ) ) ) , ( "{foo}suffix" , Ok ( ( ) ) ) ] ) . run ( )
21+ fn missing_leading_slash_suffix ( ) {
22+ InsertTest ( vec ! [ ( "/{foo}" , Ok ( ( ) ) ) , ( "/{foo}suffix" , Ok ( ( ) ) ) ] ) . run ( ) ;
23+ InsertTest ( vec ! [ ( "{foo}" , Ok ( ( ) ) ) , ( "{foo}suffix" , Ok ( ( ) ) ) ] ) . run ( ) ;
24+ }
25+
26+ // Regression test for https://github.com/ibraheemdev/matchit/issues/82.
27+ #[ test]
28+ fn missing_leading_slash_conflict ( ) {
29+ InsertTest ( vec ! [ ( "{foo}/" , Ok ( ( ) ) ) , ( "foo/" , Ok ( ( ) ) ) ] ) . run ( ) ;
30+ InsertTest ( vec ! [ ( "foo/" , Ok ( ( ) ) ) , ( "{foo}/" , Ok ( ( ) ) ) ] ) . run ( ) ;
2331}
2432
2533#[ test]
You can’t perform that action at this time.
0 commit comments