deps: path-to-regexp@0.1.8 (#5603) · expressjs/express@c5addb9 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
1 1 unreleased
2 2 ==========
3 3
4 +* deps: path-to-regexp@0.1.8
5 +- Adds support for named matching groups in the routes using a regex
4 6 * deps: encodeurl@~2.0.0
5 7 - Removes encoding of `\`, `|`, and `^` to align better with URL spec
6 8 * Deprecate passing `options.maxAge` and `options.expires` to `res.clearCookie`
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@
47 47 "methods": "~1.1.2",
48 48 "on-finished": "2.4.1",
49 49 "parseurl": "~1.3.3",
50 -"path-to-regexp": "0.1.7",
50 +"path-to-regexp": "0.1.8",
51 51 "proxy-addr": "~2.0.7",
52 52 "qs": "6.11.0",
53 53 "range-parser": "~1.2.1",
Original file line number Diff line number Diff line change
@@ -193,6 +193,23 @@ describe('app.router', function(){
193 193 .expect('editing user 10', done);
194 194 })
195 195
196 +if (supportsRegexp('(?.*)')) {
197 +it('should populate req.params with named captures', function(done){
198 +var app = express();
199 +var re = new RegExp('^/user/(?[0-9]+)/(view|edit)?$');
200 +
201 +app.get(re, function(req, res){
202 +var id = req.params.userId
203 +, op = req.params[0];
204 +res.end(op + 'ing user ' + id);
205 +});
206 +
207 +request(app)
208 +.get('/user/10/edit')
209 +.expect('editing user 10', done);
210 +})
211 +}
212 +
196 213 it('should ensure regexp matches path prefix', function (done) {
197 214 var app = express()
198 215 var p = []
@@ -1114,3 +1131,12 @@ describe('app.router', function(){
1114 1131 assert.strictEqual(app.get('/', function () {}), app)
1115 1132 })
1116 1133 })
1134 +
1135 +function supportsRegexp(source) {
1136 +try {
1137 +new RegExp(source)
1138 +return true
1139 +} catch (e) {
1140 +return false
1141 +}
1142 +}