@@ -9,16 +9,26 @@ describe("href", () => {
99 expect ( href ( "/a/:b" , { b : "hello" , z : "ignored" } ) ) . toBe ( "/a/hello" ) ;
1010 expect ( href ( "/a/:b?" , { b : "hello" , z : "ignored" } ) ) . toBe ( "/a/hello" ) ;
1111 expect ( href ( "/a/:b?" ) ) . toBe ( "/a" ) ;
12+ expect ( href ( "/:b?" ) ) . toBe ( "/" ) ;
13+ expect ( href ( "/a/:e-z" , { "e-z" : "hello" } ) ) . toBe ( "/a/hello" ) ;
1214 } ) ;
1315
1416 it ( "works with repeated params" , ( ) => {
1517 expect ( href ( "/a/:b?/:b/:b?/:b" , { b : "hello" } ) ) . toBe (
1618 "/a/hello/hello/hello/hello"
1719 ) ;
20+ expect ( href ( "/a/:c?/:b/:c?/:b" , { b : "hello" } ) ) . toBe ( "/a/hello/hello" ) ;
1821 } ) ;
1922
2023 it ( "works with splats" , ( ) => {
2124 expect ( href ( "/a/*" , { "*" : "b/c" } ) ) . toBe ( "/a/b/c" ) ;
25+ expect ( href ( "/a/*" , { } ) ) . toBe ( "/a" ) ;
26+ } ) ;
27+
28+ it ( "works with malformed splats" , ( ) => {
29+ // this is how packages\react-router\lib\router\utils.ts: compilePath() will handle these routes.
30+ expect ( href ( "/a/z*" , { "*" : "b/c" } ) ) . toBe ( "/a/z/b/c" ) ;
31+ expect ( href ( "/a/z*" , { } ) ) . toBe ( "/a/z" ) ;
2232 } ) ;
2333
2434 it ( "throws when required params are missing" , ( ) => {
@@ -29,5 +39,5 @@ describe("href", () => {
2939
3040 it ( "works with periods" , ( ) => {
3141 expect ( href ( "/a/:b.zip" , { b : "hello" } ) ) . toBe ( "/a/hello.zip" ) ;
32- } )
42+ } ) ;
3343} ) ;
0 commit comments