Skip to content

Commit 647563f

Browse files
committed
deps: path-to-regexp@0.1.8
1 parent 6da57c7 commit 647563f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

History.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
unreleased
2+
==========
3+
4+
* deps: path-to-regexp@0.1.8
5+
- Adds support for named matching groups in the routes using a regex
6+
17
4.19.2 / 2024-03-25
28
==========
39

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"methods": "~1.1.2",
4848
"on-finished": "2.4.1",
4949
"parseurl": "~1.3.3",
50-
"path-to-regexp": "0.1.7",
50+
"path-to-regexp": "0.1.8",
5151
"proxy-addr": "~2.0.7",
5252
"qs": "6.11.0",
5353
"range-parser": "~1.2.1",

test/app.router.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ describe('app.router', function(){
188188
.expect('editing user 10', done);
189189
})
190190

191+
if (supportsRegexp('(?<foo>.*)')) {
192+
it('should populate req.params with named captures', function(done){
193+
var app = express();
194+
var re = new RegExp('^/user/(?<userId>[0-9]+)/(view|edit)?$');
195+
196+
app.get(re, function(req, res){
197+
var id = req.params.userId
198+
, op = req.params[0];
199+
res.end(op + 'ing user ' + id);
200+
});
201+
202+
request(app)
203+
.get('/user/10/edit')
204+
.expect('editing user 10', done);
205+
})
206+
}
207+
191208
it('should ensure regexp matches path prefix', function (done) {
192209
var app = express()
193210
var p = []
@@ -1109,3 +1126,12 @@ describe('app.router', function(){
11091126
assert.strictEqual(app.get('/', function () {}), app)
11101127
})
11111128
})
1129+
1130+
function supportsRegexp(source) {
1131+
try {
1132+
new RegExp(source)
1133+
return true
1134+
} catch (e) {
1135+
return false
1136+
}
1137+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy