File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change
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
+
1
7
4.19.2 / 2024-03-25
2
8
==========
3
9
Original file line number Diff line number Diff line change 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 @@ -188,6 +188,23 @@ describe('app.router', function(){
188
188
. expect ( 'editing user 10' , done ) ;
189
189
} )
190
190
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
+
191
208
it ( 'should ensure regexp matches path prefix' , function ( done ) {
192
209
var app = express ( )
193
210
var p = [ ]
@@ -1109,3 +1126,12 @@ describe('app.router', function(){
1109
1126
assert . strictEqual ( app . get ( '/' , function ( ) { } ) , app )
1110
1127
} )
1111
1128
} )
1129
+
1130
+ function supportsRegexp ( source ) {
1131
+ try {
1132
+ new RegExp ( source )
1133
+ return true
1134
+ } catch ( e ) {
1135
+ return false
1136
+ }
1137
+ }
You can’t perform that action at this time.
0 commit comments