Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: path-to-regexp@0.1.8 #5603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
unreleased
==========

* deps: path-to-regexp@0.1.8
- Adds support for named matching groups in the routes using a regex

4.19.2 / 2024-03-25
==========

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 26 additions & 0 deletions test/app.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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 = []
Expand Down Expand Up @@ -1109,3 +1126,12 @@ describe('app.router', function(){
assert.strictEqual(app.get('/', function () {}), app)
})
})

function supportsRegexp(source) {
try {
new RegExp(source)
return true
} catch (e) {
return false
}
}