Skip to content

Commit efc788a

Browse files
committed
Put test behind a compat flag
1 parent ee43218 commit efc788a

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/app.router.js

+22-11
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,21 @@ describe('app.router', function(){
188188
.expect('editing user 10', done);
189189
})
190190

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();
193194

194-
app.get(/^\/user\/(?<userId>[0-9]+)\/(view|edit)?$/, 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(/^\/user\/(?<userId>[0-9]+)\/(view|edit)?$/, function(req, res){
196+
var id = req.params.userId
197+
, op = req.params[0];
198+
res.end(op + 'ing user ' + id);
199+
});
199200

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+
}
204206

205207
it('should ensure regexp matches path prefix', function (done) {
206208
var app = express()
@@ -1123,3 +1125,12 @@ describe('app.router', function(){
11231125
assert.strictEqual(app.get('/', function () {}), app)
11241126
})
11251127
})
1128+
1129+
function supportsRegexp(source) {
1130+
try {
1131+
new RegExp(source)
1132+
return true
1133+
} catch (e) {
1134+
return false
1135+
}
1136+
}

0 commit comments

Comments
 (0)