@@ -46,7 +46,8 @@ before(function(cb) {
46
46
dtrace : helper . dtrace ,
47
47
handleUncaughtExceptions : true ,
48
48
log : helper . getLog ( 'server' ) ,
49
- version : [ '2.0.0' , '0.5.4' , '1.4.3' ]
49
+ version : [ '2.0.0' , '0.5.4' , '1.4.3' ] ,
50
+ ignoreTrailingSlash : true
50
51
} ) ;
51
52
SERVER . listen ( PORT , '127.0.0.1' , function ( ) {
52
53
PORT = SERVER . address ( ) . port ;
@@ -159,6 +160,85 @@ test('get (path only)', function(t) {
159
160
} ) ;
160
161
} ) ;
161
162
163
+ test ( 'get (path only - with trailing slash)' , function ( t ) {
164
+ SERVER . get ( '/foo/' , function echoId ( req , res , next ) {
165
+ res . send ( ) ;
166
+ next ( ) ;
167
+ } ) ;
168
+
169
+ var count = 0 ;
170
+
171
+ CLIENT . get ( '/foo/' , function ( err , _ , res ) {
172
+ t . ifError ( err ) ;
173
+ t . equal ( res . statusCode , 200 ) ;
174
+
175
+ if ( ++ count === 2 ) {
176
+ t . end ( ) ;
177
+ }
178
+ } ) ;
179
+
180
+ CLIENT . get ( '/foo' , function ( err , _ , res ) {
181
+ t . ifError ( err ) ;
182
+ t . equal ( res . statusCode , 200 ) ;
183
+
184
+ if ( ++ count === 2 ) {
185
+ t . end ( ) ;
186
+ }
187
+ } ) ;
188
+ } ) ;
189
+
190
+ test ( 'get (path only - with trailing slash and nested route)' , function ( t ) {
191
+ SERVER . get ( '/foo/' , function echoId ( req , res , next ) {
192
+ res . statusCode = 200 ;
193
+ res . send ( ) ;
194
+ next ( ) ;
195
+ } ) ;
196
+
197
+ SERVER . get ( '/foo/bar' , function echoId ( req , res , next ) {
198
+ res . statusCode = 201 ;
199
+ res . send ( ) ;
200
+ next ( ) ;
201
+ } ) ;
202
+
203
+ var count = 0 ;
204
+
205
+ CLIENT . get ( '/foo/' , function ( err , _ , res ) {
206
+ t . ifError ( err ) ;
207
+ t . equal ( res . statusCode , 200 ) ;
208
+
209
+ if ( ++ count === 4 ) {
210
+ t . end ( ) ;
211
+ }
212
+ } ) ;
213
+
214
+ CLIENT . get ( '/foo' , function ( err , _ , res ) {
215
+ t . ifError ( err ) ;
216
+ t . equal ( res . statusCode , 200 ) ;
217
+
218
+ if ( ++ count === 4 ) {
219
+ t . end ( ) ;
220
+ }
221
+ } ) ;
222
+
223
+ CLIENT . get ( '/foo/bar/' , function ( err , _ , res ) {
224
+ t . ifError ( err ) ;
225
+ t . equal ( res . statusCode , 201 ) ;
226
+
227
+ if ( ++ count === 4 ) {
228
+ t . end ( ) ;
229
+ }
230
+ } ) ;
231
+
232
+ CLIENT . get ( '/foo/bar' , function ( err , _ , res ) {
233
+ t . ifError ( err ) ;
234
+ t . equal ( res . statusCode , 201 ) ;
235
+
236
+ if ( ++ count === 4 ) {
237
+ t . end ( ) ;
238
+ }
239
+ } ) ;
240
+ } ) ;
241
+
162
242
test ( 'use + get (path only)' , function ( t ) {
163
243
SERVER . use ( function ( req , res , next ) {
164
244
next ( ) ;
0 commit comments