@@ -316,12 +316,12 @@ describe('app.router', function(){
316
316
var app = express ( ) ;
317
317
var router = new express . Router ( { mergeParams : true } ) ;
318
318
319
- router . get ( '/ (.*).(.*)' , function ( req , res ) {
319
+ router . get ( / ^ \/ ( .* ) \ .( .* ) / , function ( req , res ) {
320
320
var keys = Object . keys ( req . params ) . sort ( ) ;
321
321
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
322
322
} ) ;
323
323
324
- app . use ( '/ user/id:(\\ d+)' , router ) ;
324
+ app . use ( / ^ \/ u s e r \ /i d : ( \d + ) / , router ) ;
325
325
326
326
request ( app )
327
327
. get ( '/user/id:10/profile.json' )
@@ -332,12 +332,12 @@ describe('app.router', function(){
332
332
var app = express ( ) ;
333
333
var router = new express . Router ( { mergeParams : true } ) ;
334
334
335
- router . get ( '/ (.*)' , function ( req , res ) {
335
+ router . get ( / \/ ( .* ) / , function ( req , res ) {
336
336
var keys = Object . keys ( req . params ) . sort ( ) ;
337
337
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
338
338
} ) ;
339
339
340
- app . use ( '/ user/id:(\\ d+)/name:(\\ w+)' , router ) ;
340
+ app . use ( / ^ \/ u s e r \ /i d : ( \d + ) \ /n a m e : ( \w + ) / , router ) ;
341
341
342
342
request ( app )
343
343
. get ( '/user/id:10/name:tj/profile' )
@@ -348,12 +348,12 @@ describe('app.router', function(){
348
348
var app = express ( ) ;
349
349
var router = new express . Router ( { mergeParams : true } ) ;
350
350
351
- router . get ( '/ name:(\\ w+)' , function ( req , res ) {
351
+ router . get ( / \/ n a m e : ( \w + ) / , function ( req , res ) {
352
352
var keys = Object . keys ( req . params ) . sort ( ) ;
353
353
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
354
354
} ) ;
355
355
356
- app . use ( '/ user/id:(\\ d+)' , router ) ;
356
+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , router ) ;
357
357
358
358
request ( app )
359
359
. get ( '/user/id:10/name:tj' )
@@ -383,11 +383,11 @@ describe('app.router', function(){
383
383
var app = express ( ) ;
384
384
var router = new express . Router ( { mergeParams : true } ) ;
385
385
386
- router . get ( '/ user:(\\ w+)/*' , function ( req , res , next ) {
386
+ router . get ( / \/ u s e r : ( \w + ) \/ / , function ( req , res , next ) {
387
387
next ( ) ;
388
388
} ) ;
389
389
390
- app . use ( '/ user/id:(\\ d+)' , function ( req , res , next ) {
390
+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , function ( req , res , next ) {
391
391
router ( req , res , function ( err ) {
392
392
var keys = Object . keys ( req . params ) . sort ( ) ;
393
393
res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
@@ -610,8 +610,8 @@ describe('app.router', function(){
610
610
var app = express ( ) ;
611
611
var cb = after ( 2 , done ) ;
612
612
613
- app . get ( '/user(s?) /:user/:op' , function ( req , res ) {
614
- res . end ( req . params . op + 'ing ' + req . params . user + ( req . params [ 0 ] ? ' (old)' : '' ) ) ;
613
+ app . get ( '/user{s} /:user/:op' , function ( req , res ) {
614
+ res . end ( req . params . op + 'ing ' + req . params . user + ( req . url . startsWith ( '/users' ) ? ' (old)' : '' ) ) ;
615
615
} ) ;
616
616
617
617
request ( app )
@@ -657,7 +657,7 @@ describe('app.router', function(){
657
657
it ( 'should denote an optional capture group' , function ( done ) {
658
658
var app = express ( ) ;
659
659
660
- app . get ( '/user/:user/:op? ' , function ( req , res ) {
660
+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
661
661
var op = req . params . op || 'view' ;
662
662
res . end ( op + 'ing ' + req . params . user ) ;
663
663
} ) ;
@@ -670,7 +670,7 @@ describe('app.router', function(){
670
670
it ( 'should populate the capture group' , function ( done ) {
671
671
var app = express ( ) ;
672
672
673
- app . get ( '/user/:user/:op? ' , function ( req , res ) {
673
+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
674
674
var op = req . params . op || 'view' ;
675
675
res . end ( op + 'ing ' + req . params . user ) ;
676
676
} ) ;
@@ -685,8 +685,8 @@ describe('app.router', function(){
685
685
it ( 'should match one segment' , function ( done ) {
686
686
var app = express ( )
687
687
688
- app . get ( '/user/:user* ' , function ( req , res ) {
689
- res . end ( req . params . user )
688
+ app . get ( '/user/*user ' , function ( req , res ) {
689
+ res . end ( req . params . user [ 0 ] )
690
690
} )
691
691
692
692
request ( app )
@@ -697,8 +697,8 @@ describe('app.router', function(){
697
697
it ( 'should match many segments' , function ( done ) {
698
698
var app = express ( )
699
699
700
- app . get ( '/user/:user* ' , function ( req , res ) {
701
- res . end ( req . params . user )
700
+ app . get ( '/user/*user ' , function ( req , res ) {
701
+ res . end ( req . params . user . join ( '/' ) )
702
702
} )
703
703
704
704
request ( app )
@@ -709,7 +709,7 @@ describe('app.router', function(){
709
709
it ( 'should match zero segments' , function ( done ) {
710
710
var app = express ( )
711
711
712
- app . get ( '/user/:user* ' , function ( req , res ) {
712
+ app . get ( '/user{/*user} ' , function ( req , res ) {
713
713
res . end ( req . params . user )
714
714
} )
715
715
@@ -723,8 +723,8 @@ describe('app.router', function(){
723
723
it ( 'should match one segment' , function ( done ) {
724
724
var app = express ( )
725
725
726
- app . get ( '/user/: user+ ' , function ( req , res ) {
727
- res . end ( req . params . user )
726
+ app . get ( '/user/* user' , function ( req , res ) {
727
+ res . end ( req . params . user [ 0 ] )
728
728
} )
729
729
730
730
request ( app )
@@ -735,8 +735,8 @@ describe('app.router', function(){
735
735
it ( 'should match many segments' , function ( done ) {
736
736
var app = express ( )
737
737
738
- app . get ( '/user/: user+ ' , function ( req , res ) {
739
- res . end ( req . params . user )
738
+ app . get ( '/user/* user' , function ( req , res ) {
739
+ res . end ( req . params . user . join ( '/' ) )
740
740
} )
741
741
742
742
request ( app )
@@ -747,7 +747,7 @@ describe('app.router', function(){
747
747
it ( 'should not match zero segments' , function ( done ) {
748
748
var app = express ( )
749
749
750
- app . get ( '/user/: user+ ' , function ( req , res ) {
750
+ app . get ( '/user/* user' , function ( req , res ) {
751
751
res . end ( req . params . user )
752
752
} )
753
753
@@ -781,7 +781,7 @@ describe('app.router', function(){
781
781
var app = express ( ) ;
782
782
var cb = after ( 2 , done )
783
783
784
- app . get ( '/:name.:format? ' , function ( req , res ) {
784
+ app . get ( '/:name{ .:format} ' , function ( req , res ) {
785
785
res . end ( req . params . name + ' as ' + ( req . params . format || 'html' ) ) ;
786
786
} ) ;
787
787
@@ -800,7 +800,7 @@ describe('app.router', function(){
800
800
var app = express ( )
801
801
, calls = [ ] ;
802
802
803
- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
803
+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
804
804
calls . push ( '/foo/:bar?' ) ;
805
805
next ( ) ;
806
806
} ) ;
@@ -885,7 +885,7 @@ describe('app.router', function(){
885
885
var app = express ( )
886
886
, calls = [ ] ;
887
887
888
- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
888
+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
889
889
calls . push ( '/foo/:bar?' ) ;
890
890
next ( ) ;
891
891
} ) ;
@@ -1096,7 +1096,7 @@ describe('app.router', function(){
1096
1096
var app = express ( ) ;
1097
1097
var path = [ ] ;
1098
1098
1099
- app . get ( '/: path+ ' , function ( req , res , next ) {
1099
+ app . get ( '/* path' , function ( req , res , next ) {
1100
1100
path . push ( 0 ) ;
1101
1101
next ( ) ;
1102
1102
} ) ;
@@ -1116,7 +1116,7 @@ describe('app.router', function(){
1116
1116
next ( ) ;
1117
1117
} ) ;
1118
1118
1119
- app . get ( '/(.*) ' , function ( req , res , next ) {
1119
+ app . get ( '/*splat ' , function ( req , res , next ) {
1120
1120
path . push ( 4 ) ;
1121
1121
next ( ) ;
1122
1122
} ) ;
0 commit comments