@@ -103,6 +103,32 @@ test('param :: multiple', t => {
103
103
t . end ( ) ;
104
104
} ) ;
105
105
106
+ test ( 'param :: suffix' , t => {
107
+ let { keys, pattern } = fn ( '/movies/:title.mp4' ) ;
108
+ t . same ( keys , [ 'title' ] , '~> keys has "title" only (no suffix)' ) ;
109
+ t . false ( pattern . test ( '/movies' ) , '~> does not match naked base' ) ;
110
+ t . false ( pattern . test ( '/movies/' ) , '~> does not match naked base w/ trailing slash' ) ;
111
+ t . false ( pattern . test ( '/movies/foo' ) , '~> does not match without suffix' ) ;
112
+ t . false ( pattern . test ( '/movies/foo.mp3' ) , '~> does not match with wrong suffix' ) ;
113
+ t . true ( pattern . test ( '/movies/foo.mp4' ) , '~> does match with correct suffix' ) ;
114
+ t . true ( pattern . test ( '/movies/foo.mp4/' ) , '~> does match with trailing slash' ) ;
115
+ t . end ( ) ;
116
+ } ) ;
117
+
118
+ test ( 'param :: suffices' , t => {
119
+ let { keys, pattern } = fn ( '/movies/:title.(mp4|mov)' ) ;
120
+ t . same ( keys , [ 'title' ] , '~> keys has "title" only (no suffix)' ) ;
121
+ t . false ( pattern . test ( '/movies' ) , '~> does not match naked base' ) ;
122
+ t . false ( pattern . test ( '/movies/' ) , '~> does not match naked base w/ trailing slash' ) ;
123
+ t . false ( pattern . test ( '/movies/foo' ) , '~> does not match without suffix' ) ;
124
+ t . false ( pattern . test ( '/movies/foo.mp3' ) , '~> does not match with wrong suffix' ) ;
125
+ t . true ( pattern . test ( '/movies/foo.mp4' ) , '~> does match with correct suffix (mp4)' ) ;
126
+ t . true ( pattern . test ( '/movies/foo.mp4/' ) , '~> does match with trailing slash (mp4)' ) ;
127
+ t . true ( pattern . test ( '/movies/foo.mov' ) , '~> does match with correct suffix (mov)' ) ;
128
+ t . true ( pattern . test ( '/movies/foo.mov/' ) , '~> does match with trailing slash (mov)' ) ;
129
+ t . end ( ) ;
130
+ } ) ;
131
+
106
132
test ( 'param :: optional' , t => {
107
133
let { keys, pattern } = fn ( '/books/:author/:title?' ) ;
108
134
t . same ( keys , [ 'author' , 'title' ] , '~> keys has "author" & "title" values' ) ;
0 commit comments