@@ -619,9 +619,77 @@ describe('Path parser', () => {
619
619
matchParams ( '/home' , '/other/home' , { } , { start : false } )
620
620
} )
621
621
622
+ it ( 'defaults to matching the end' , ( ) => {
623
+ // The default should behave like `end: true`
624
+ const optionSets = [ { } , { end : true } ]
625
+
626
+ for ( const options of optionSets ) {
627
+ matchParams ( '/home' , '/home' , { } , options )
628
+ matchParams ( '/home' , '/home/' , { } , options )
629
+ matchParams ( '/home' , '/home/other' , null , options )
630
+ matchParams ( '/home' , '/homepage' , null , options )
631
+
632
+ matchParams ( '/home/' , '/home' , { } , options )
633
+ matchParams ( '/home/' , '/home/' , { } , options )
634
+ matchParams ( '/home/' , '/home/other' , null , options )
635
+ matchParams ( '/home/' , '/homepage' , null , options )
636
+ }
637
+ } )
638
+
622
639
it ( 'can not match the end' , ( ) => {
623
- matchParams ( '/home' , '/home/other' , null , { end : true } )
624
- matchParams ( '/home' , '/home/other' , { } , { end : false } )
640
+ const options = { end : false }
641
+
642
+ matchParams ( '/home' , '/home' , { } , options )
643
+ matchParams ( '/home' , '/home/' , { } , options )
644
+ matchParams ( '/home' , '/home/other' , { } , options )
645
+ matchParams ( '/home' , '/homepage' , { } , options )
646
+
647
+ matchParams ( '/home/:p' , '/home' , null , options )
648
+ matchParams ( '/home/:p' , '/home/' , null , options )
649
+ matchParams ( '/home/:p' , '/home/a' , { p : 'a' } , options )
650
+ matchParams ( '/home/:p' , '/home/a/' , { p : 'a' } , options )
651
+ matchParams ( '/home/:p' , '/home/a/b' , { p : 'a' } , options )
652
+ matchParams ( '/home/:p' , '/homepage' , null , options )
653
+
654
+ matchParams ( '/home/' , '/home' , { } , options )
655
+ matchParams ( '/home/' , '/home/' , { } , options )
656
+ matchParams ( '/home/' , '/home/other' , { } , options )
657
+ matchParams ( '/home/' , '/homepage' , { } , options )
658
+
659
+ matchParams ( '/home/:p/' , '/home' , null , options )
660
+ matchParams ( '/home/:p/' , '/home/' , null , options )
661
+ matchParams ( '/home/:p/' , '/home/a' , { p : 'a' } , options )
662
+ matchParams ( '/home/:p/' , '/home/a/' , { p : 'a' } , options )
663
+ matchParams ( '/home/:p/' , '/home/a/b' , { p : 'a' } , options )
664
+ matchParams ( '/home/:p/' , '/homepage' , null , options )
665
+ } )
666
+
667
+ it ( 'can not match the end when strict' , ( ) => {
668
+ const options = { end : false , strict : true }
669
+
670
+ matchParams ( '/home' , '/home' , { } , options )
671
+ matchParams ( '/home' , '/home/' , { } , options )
672
+ matchParams ( '/home' , '/home/other' , { } , options )
673
+ matchParams ( '/home' , '/homepage' , null , options )
674
+
675
+ matchParams ( '/home/:p' , '/home' , null , options )
676
+ matchParams ( '/home/:p' , '/home/' , null , options )
677
+ matchParams ( '/home/:p' , '/home/a' , { p : 'a' } , options )
678
+ matchParams ( '/home/:p' , '/home/a/' , { p : 'a' } , options )
679
+ matchParams ( '/home/:p' , '/home/a/b' , { p : 'a' } , options )
680
+ matchParams ( '/home/:p' , '/homepage' , null , options )
681
+
682
+ matchParams ( '/home/' , '/home' , null , options )
683
+ matchParams ( '/home/' , '/home/' , { } , options )
684
+ matchParams ( '/home/' , '/home/other' , { } , options )
685
+ matchParams ( '/home/' , '/homepage' , null , options )
686
+
687
+ matchParams ( '/home/:p/' , '/home' , null , options )
688
+ matchParams ( '/home/:p/' , '/home/' , null , options )
689
+ matchParams ( '/home/:p/' , '/home/a' , null , options )
690
+ matchParams ( '/home/:p/' , '/home/a/' , { p : 'a' } , options )
691
+ matchParams ( '/home/:p/' , '/home/a/b' , { p : 'a' } , options )
692
+ matchParams ( '/home/:p/' , '/homepage' , null , options )
625
693
} )
626
694
627
695
it ( 'should not match optional params + static without leading slash' , ( ) => {
0 commit comments