File tree 1 file changed +22
-11
lines changed
1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -188,19 +188,21 @@ describe('app.router', function(){
188
188
. expect ( 'editing user 10' , done ) ;
189
189
} )
190
190
191
- it ( 'should populate req.params with named captures' , function ( done ) {
192
- var app = express ( ) ;
191
+ if ( supportsRegexp ( '(?<foo>.*)' ) ) {
192
+ it ( 'should populate req.params with named captures' , function ( done ) {
193
+ var app = express ( ) ;
193
194
194
- app . get ( / ^ \/ u s e r \/ (?< userId > [ 0 - 9 ] + ) \/ ( v i e w | e d i t ) ? $ / , function ( req , res ) {
195
- var id = req . params . userId
196
- , op = req . params [ 0 ] ;
197
- res . end ( op + 'ing user ' + id ) ;
198
- } ) ;
195
+ app . get ( / ^ \/ u s e r \/ (?< userId > [ 0 - 9 ] + ) \/ ( v i e w | e d i t ) ? $ / , function ( req , res ) {
196
+ var id = req . params . userId
197
+ , op = req . params [ 0 ] ;
198
+ res . end ( op + 'ing user ' + id ) ;
199
+ } ) ;
199
200
200
- request ( app )
201
- . get ( '/user/10/edit' )
202
- . expect ( 'editing user 10' , done ) ;
203
- } )
201
+ request ( app )
202
+ . get ( '/user/10/edit' )
203
+ . expect ( 'editing user 10' , done ) ;
204
+ } )
205
+ }
204
206
205
207
it ( 'should ensure regexp matches path prefix' , function ( done ) {
206
208
var app = express ( )
@@ -1123,3 +1125,12 @@ describe('app.router', function(){
1123
1125
assert . strictEqual ( app . get ( '/' , function ( ) { } ) , app )
1124
1126
} )
1125
1127
} )
1128
+
1129
+ function supportsRegexp ( source ) {
1130
+ try {
1131
+ new RegExp ( source )
1132
+ return true
1133
+ } catch ( e ) {
1134
+ return false
1135
+ }
1136
+ }
You can’t perform that action at this time.
0 commit comments