@@ -47,6 +47,14 @@ describe("route(root, path, exts)", () => {
47
47
it ( "finds a non-parameterized file ahead of a parameterized file" , ( ) => {
48
48
assert . deepStrictEqual ( route ( "test/input/params" , "foo" , [ ".md" ] ) , { path : "foo.md" , ext : ".md" } ) ; // prettier-ignore
49
49
} ) ;
50
+ it ( "maps a bracketed parameter onto itself" , ( ) => {
51
+ assert . deepStrictEqual ( route ( "test/input/params" , "[dir]/[file]" , [ ".md" ] ) , { path : "[dir]/[file].md" , ext : ".md" , params : { dir : "[dir]" , file : "[file]" } } ) ; // prettier-ignore
52
+ assert . deepStrictEqual ( route ( "test/input/params" , "[dir]/foo" , [ ".md" ] ) , { path : "[dir]/foo.md" , ext : ".md" , params : { dir : "[dir]" } } ) ; // prettier-ignore
53
+ assert . deepStrictEqual ( route ( "test/input/params" , "[dir]/[baz]" , [ ".md" ] ) , { path : "[dir]/[file].md" , ext : ".md" , params : { dir : "[dir]" , file : "[baz]" } } ) ; // prettier-ignore
54
+ assert . deepStrictEqual ( route ( "test/input/params" , "foo/[file]" , [ ".md" ] ) , { path : "foo/[file].md" , ext : ".md" , params : { file : "[file]" } } ) ; // prettier-ignore
55
+ assert . deepStrictEqual ( route ( "test/input/params" , "[foo]-suffix" , [ ".js" ] ) , { path : "[file]-suffix.js" , ext : ".js" , params : { file : "[foo]" } } ) ; // prettier-ignore
56
+ assert . deepStrictEqual ( route ( "test/input/params" , "[file]-suffix" , [ ".js" ] ) , { path : "[file]-suffix.js" , ext : ".js" , params : { file : "[file]" } } ) ; // prettier-ignore
57
+ } ) ;
50
58
it ( "finds the most-specific parameterized match" , ( ) => {
51
59
assert . deepStrictEqual ( route ( "test/input/params" , "foo/foo" , [ ".md" ] ) , { path : "foo/foo.md" , ext : ".md" } ) ; // prettier-ignore
52
60
assert . deepStrictEqual ( route ( "test/input/params" , "foo/bar" , [ ".md" ] ) , { path : "foo/[file].md" , ext : ".md" , params : { file : "bar" } } ) ; // prettier-ignore
0 commit comments