mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 00:19:48 +01:00
deps: path-to-regexp@0.1.8 (#5603)
This commit is contained in:
parent
e35380a39d
commit
c5addb9a17
|
|
@ -1,6 +1,8 @@
|
|||
unreleased
|
||||
==========
|
||||
|
||||
* deps: path-to-regexp@0.1.8
|
||||
- Adds support for named matching groups in the routes using a regex
|
||||
* deps: encodeurl@~2.0.0
|
||||
- Removes encoding of `\`, `|`, and `^` to align better with URL spec
|
||||
* Deprecate passing `options.maxAge` and `options.expires` to `res.clearCookie`
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
"methods": "~1.1.2",
|
||||
"on-finished": "2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"path-to-regexp": "0.1.8",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "6.11.0",
|
||||
"range-parser": "~1.2.1",
|
||||
|
|
|
|||
|
|
@ -193,6 +193,23 @@ describe('app.router', function(){
|
|||
.expect('editing user 10', done);
|
||||
})
|
||||
|
||||
if (supportsRegexp('(?<foo>.*)')) {
|
||||
it('should populate req.params with named captures', function(done){
|
||||
var app = express();
|
||||
var re = new RegExp('^/user/(?<userId>[0-9]+)/(view|edit)?$');
|
||||
|
||||
app.get(re, function(req, res){
|
||||
var id = req.params.userId
|
||||
, op = req.params[0];
|
||||
res.end(op + 'ing user ' + id);
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/user/10/edit')
|
||||
.expect('editing user 10', done);
|
||||
})
|
||||
}
|
||||
|
||||
it('should ensure regexp matches path prefix', function (done) {
|
||||
var app = express()
|
||||
var p = []
|
||||
|
|
@ -1114,3 +1131,12 @@ describe('app.router', function(){
|
|||
assert.strictEqual(app.get('/', function () {}), app)
|
||||
})
|
||||
})
|
||||
|
||||
function supportsRegexp(source) {
|
||||
try {
|
||||
new RegExp(source)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user