@@ -337,12 +337,12 @@ describe('app.router', function(){
337
337
var app = express ( ) ;
338
338
var router = new express . Router ( { mergeParams : true } ) ;
339
339
340
- router . get ( '/ (.*).(.*)' , function ( req , res ) {
340
+ router . get ( / ^ \/ ( .* ) \ .( .* ) / , function ( req , res ) {
341
341
var keys = Object . keys ( req . params ) . sort ( ) ;
342
342
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
343
343
} ) ;
344
344
345
- app . use ( '/ user/id:(\\ d+)' , router ) ;
345
+ app . use ( / ^ \/ u s e r \ /i d : ( \d + ) / , router ) ;
346
346
347
347
request ( app )
348
348
. get ( '/user/id:10/profile.json' )
@@ -353,12 +353,12 @@ describe('app.router', function(){
353
353
var app = express ( ) ;
354
354
var router = new express . Router ( { mergeParams : true } ) ;
355
355
356
- router . get ( '/ (.*)' , function ( req , res ) {
356
+ router . get ( / \/ ( .* ) / , function ( req , res ) {
357
357
var keys = Object . keys ( req . params ) . sort ( ) ;
358
358
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
359
359
} ) ;
360
360
361
- app . use ( '/ user/id:(\\ d+)/name:(\\ w+)' , router ) ;
361
+ app . use ( / ^ \/ u s e r \ /i d : ( \d + ) \ /n a m e : ( \w + ) / , router ) ;
362
362
363
363
request ( app )
364
364
. get ( '/user/id:10/name:tj/profile' )
@@ -369,12 +369,12 @@ describe('app.router', function(){
369
369
var app = express ( ) ;
370
370
var router = new express . Router ( { mergeParams : true } ) ;
371
371
372
- router . get ( '/ name:(\\ w+)' , function ( req , res ) {
372
+ router . get ( / \/ n a m e : ( \w + ) / , function ( req , res ) {
373
373
var keys = Object . keys ( req . params ) . sort ( ) ;
374
374
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
375
375
} ) ;
376
376
377
- app . use ( '/ user/id:(\\ d+)' , router ) ;
377
+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , router ) ;
378
378
379
379
request ( app )
380
380
. get ( '/user/id:10/name:tj' )
@@ -404,11 +404,11 @@ describe('app.router', function(){
404
404
var app = express ( ) ;
405
405
var router = new express . Router ( { mergeParams : true } ) ;
406
406
407
- router . get ( '/ user:(\\ w+)/*' , function ( req , res , next ) {
407
+ router . get ( / \/ u s e r : ( \w + ) \/ / , function ( req , res , next ) {
408
408
next ( ) ;
409
409
} ) ;
410
410
411
- app . use ( '/ user/id:(\\ d+)' , function ( req , res , next ) {
411
+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , function ( req , res , next ) {
412
412
router ( req , res , function ( err ) {
413
413
var keys = Object . keys ( req . params ) . sort ( ) ;
414
414
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
@@ -631,8 +631,8 @@ describe('app.router', function(){
631
631
var app = express ( ) ;
632
632
var cb = after ( 2 , done ) ;
633
633
634
- app . get ( '/user(s?) /:user/:op' , function ( req , res ) {
635
- res . end ( req . params . op + 'ing ' + req . params . user + ( req . params [ 0 ] ? ' (old)' : '' ) ) ;
634
+ app . get ( '/user{s} /:user/:op' , function ( req , res ) {
635
+ res . end ( req . params . op + 'ing ' + req . params . user + ( req . url . startsWith ( '/users' ) ? ' (old)' : '' ) ) ;
636
636
} ) ;
637
637
638
638
request ( app )
@@ -678,7 +678,7 @@ describe('app.router', function(){
678
678
it ( 'should denote an optional capture group' , function ( done ) {
679
679
var app = express ( ) ;
680
680
681
- app . get ( '/user/:user/:op? ' , function ( req , res ) {
681
+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
682
682
var op = req . params . op || 'view' ;
683
683
res . end ( op + 'ing ' + req . params . user ) ;
684
684
} ) ;
@@ -691,7 +691,7 @@ describe('app.router', function(){
691
691
it ( 'should populate the capture group' , function ( done ) {
692
692
var app = express ( ) ;
693
693
694
- app . get ( '/user/:user/:op? ' , function ( req , res ) {
694
+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
695
695
var op = req . params . op || 'view' ;
696
696
res . end ( op + 'ing ' + req . params . user ) ;
697
697
} ) ;
@@ -706,8 +706,8 @@ describe('app.router', function(){
706
706
it ( 'should match one segment' , function ( done ) {
707
707
var app = express ( )
708
708
709
- app . get ( '/user/:user* ' , function ( req , res ) {
710
- res . end ( req . params . user )
709
+ app . get ( '/user/*user ' , function ( req , res ) {
710
+ res . end ( req . params . user [ 0 ] )
711
711
} )
712
712
713
713
request ( app )
@@ -718,8 +718,8 @@ describe('app.router', function(){
718
718
it ( 'should match many segments' , function ( done ) {
719
719
var app = express ( )
720
720
721
- app . get ( '/user/:user* ' , function ( req , res ) {
722
- res . end ( req . params . user )
721
+ app . get ( '/user/*user ' , function ( req , res ) {
722
+ res . end ( req . params . user . join ( '/' ) )
723
723
} )
724
724
725
725
request ( app )
@@ -730,7 +730,7 @@ describe('app.router', function(){
730
730
it ( 'should match zero segments' , function ( done ) {
731
731
var app = express ( )
732
732
733
- app . get ( '/user/:user* ' , function ( req , res ) {
733
+ app . get ( '/user{/*user} ' , function ( req , res ) {
734
734
res . end ( req . params . user )
735
735
} )
736
736
@@ -744,8 +744,8 @@ describe('app.router', function(){
744
744
it ( 'should match one segment' , function ( done ) {
745
745
var app = express ( )
746
746
747
- app . get ( '/user/: user+ ' , function ( req , res ) {
748
- res . end ( req . params . user )
747
+ app . get ( '/user/* user' , function ( req , res ) {
748
+ res . end ( req . params . user [ 0 ] )
749
749
} )
750
750
751
751
request ( app )
@@ -756,8 +756,8 @@ describe('app.router', function(){
756
756
it ( 'should match many segments' , function ( done ) {
757
757
var app = express ( )
758
758
759
- app . get ( '/user/: user+ ' , function ( req , res ) {
760
- res . end ( req . params . user )
759
+ app . get ( '/user/* user' , function ( req , res ) {
760
+ res . end ( req . params . user . join ( '/' ) )
761
761
} )
762
762
763
763
request ( app )
@@ -768,7 +768,7 @@ describe('app.router', function(){
768
768
it ( 'should not match zero segments' , function ( done ) {
769
769
var app = express ( )
770
770
771
- app . get ( '/user/: user+ ' , function ( req , res ) {
771
+ app . get ( '/user/* user' , function ( req , res ) {
772
772
res . end ( req . params . user )
773
773
} )
774
774
@@ -802,7 +802,7 @@ describe('app.router', function(){
802
802
var app = express ( ) ;
803
803
var cb = after ( 2 , done )
804
804
805
- app . get ( '/:name.:format? ' , function ( req , res ) {
805
+ app . get ( '/:name{ .:format} ' , function ( req , res ) {
806
806
res . end ( req . params . name + ' as ' + ( req . params . format || 'html' ) ) ;
807
807
} ) ;
808
808
@@ -821,7 +821,7 @@ describe('app.router', function(){
821
821
var app = express ( )
822
822
, calls = [ ] ;
823
823
824
- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
824
+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
825
825
calls . push ( '/foo/:bar?' ) ;
826
826
next ( ) ;
827
827
} ) ;
@@ -906,7 +906,7 @@ describe('app.router', function(){
906
906
var app = express ( )
907
907
, calls = [ ] ;
908
908
909
- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
909
+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
910
910
calls . push ( '/foo/:bar?' ) ;
911
911
next ( ) ;
912
912
} ) ;
@@ -1117,7 +1117,7 @@ describe('app.router', function(){
1117
1117
var app = express ( ) ;
1118
1118
var path = [ ] ;
1119
1119
1120
- app . get ( '/: path+ ' , function ( req , res , next ) {
1120
+ app . get ( '/* path' , function ( req , res , next ) {
1121
1121
path . push ( 0 ) ;
1122
1122
next ( ) ;
1123
1123
} ) ;
@@ -1137,7 +1137,7 @@ describe('app.router', function(){
1137
1137
next ( ) ;
1138
1138
} ) ;
1139
1139
1140
- app . get ( '/(.*) ' , function ( req , res , next ) {
1140
+ app . get ( '/*splat ' , function ( req , res , next ) {
1141
1141
path . push ( 4 ) ;
1142
1142
next ( ) ;
1143
1143
} ) ;
0 commit comments