@@ -316,12 +316,12 @@ describe('app.router', function(){
316316 var app = express ( ) ;
317317 var router = new express . Router ( { mergeParams : true } ) ;
318318
319- router . get ( '/ (.*).(.*)' , function ( req , res ) {
319+ router . get ( / ^ \/ ( .* ) \ .( .* ) / , function ( req , res ) {
320320 var keys = Object . keys ( req . params ) . sort ( ) ;
321321 res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
322322 } ) ;
323323
324- app . use ( '/ user/id:(\\ d+)' , router ) ;
324+ app . use ( / ^ \/ u s e r \ /i d : ( \d + ) / , router ) ;
325325
326326 request ( app )
327327 . get ( '/user/id:10/profile.json' )
@@ -332,12 +332,12 @@ describe('app.router', function(){
332332 var app = express ( ) ;
333333 var router = new express . Router ( { mergeParams : true } ) ;
334334
335- router . get ( '/ (.*)' , function ( req , res ) {
335+ router . get ( / \/ ( .* ) / , function ( req , res ) {
336336 var keys = Object . keys ( req . params ) . sort ( ) ;
337337 res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
338338 } ) ;
339339
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 ) ;
341341
342342 request ( app )
343343 . get ( '/user/id:10/name:tj/profile' )
@@ -348,12 +348,12 @@ describe('app.router', function(){
348348 var app = express ( ) ;
349349 var router = new express . Router ( { mergeParams : true } ) ;
350350
351- router . get ( '/ name:(\\ w+)' , function ( req , res ) {
351+ router . get ( / \/ n a m e : ( \w + ) / , function ( req , res ) {
352352 var keys = Object . keys ( req . params ) . sort ( ) ;
353353 res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
354354 } ) ;
355355
356- app . use ( '/ user/id:(\\ d+)' , router ) ;
356+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , router ) ;
357357
358358 request ( app )
359359 . get ( '/user/id:10/name:tj' )
@@ -383,11 +383,11 @@ describe('app.router', function(){
383383 var app = express ( ) ;
384384 var router = new express . Router ( { mergeParams : true } ) ;
385385
386- router . get ( '/ user:(\\ w+)/*' , function ( req , res , next ) {
386+ router . get ( / \/ u s e r : ( \w + ) \/ / , function ( req , res , next ) {
387387 next ( ) ;
388388 } ) ;
389389
390- app . use ( '/ user/id:(\\ d+)' , function ( req , res , next ) {
390+ app . use ( / \/ u s e r \ /i d : ( \d + ) / , function ( req , res , next ) {
391391 router ( req , res , function ( err ) {
392392 var keys = Object . keys ( req . params ) . sort ( ) ;
393393 res . send ( keys . map ( function ( k ) { return [ k , req . params [ k ] ] } ) ) ;
@@ -610,8 +610,8 @@ describe('app.router', function(){
610610 var app = express ( ) ;
611611 var cb = after ( 2 , done ) ;
612612
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)' : '' ) ) ;
615615 } ) ;
616616
617617 request ( app )
@@ -657,7 +657,7 @@ describe('app.router', function(){
657657 it ( 'should denote an optional capture group' , function ( done ) {
658658 var app = express ( ) ;
659659
660- app . get ( '/user/:user/:op? ' , function ( req , res ) {
660+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
661661 var op = req . params . op || 'view' ;
662662 res . end ( op + 'ing ' + req . params . user ) ;
663663 } ) ;
@@ -670,7 +670,7 @@ describe('app.router', function(){
670670 it ( 'should populate the capture group' , function ( done ) {
671671 var app = express ( ) ;
672672
673- app . get ( '/user/:user/:op? ' , function ( req , res ) {
673+ app . get ( '/user/:user{ /:op} ' , function ( req , res ) {
674674 var op = req . params . op || 'view' ;
675675 res . end ( op + 'ing ' + req . params . user ) ;
676676 } ) ;
@@ -685,8 +685,8 @@ describe('app.router', function(){
685685 it ( 'should match one segment' , function ( done ) {
686686 var app = express ( )
687687
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 ] )
690690 } )
691691
692692 request ( app )
@@ -697,8 +697,8 @@ describe('app.router', function(){
697697 it ( 'should match many segments' , function ( done ) {
698698 var app = express ( )
699699
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 ( '/' ) )
702702 } )
703703
704704 request ( app )
@@ -709,7 +709,7 @@ describe('app.router', function(){
709709 it ( 'should match zero segments' , function ( done ) {
710710 var app = express ( )
711711
712- app . get ( '/user/:user* ' , function ( req , res ) {
712+ app . get ( '/user{/*user} ' , function ( req , res ) {
713713 res . end ( req . params . user )
714714 } )
715715
@@ -723,8 +723,8 @@ describe('app.router', function(){
723723 it ( 'should match one segment' , function ( done ) {
724724 var app = express ( )
725725
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 ] )
728728 } )
729729
730730 request ( app )
@@ -735,8 +735,8 @@ describe('app.router', function(){
735735 it ( 'should match many segments' , function ( done ) {
736736 var app = express ( )
737737
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 ( '/' ) )
740740 } )
741741
742742 request ( app )
@@ -747,7 +747,7 @@ describe('app.router', function(){
747747 it ( 'should not match zero segments' , function ( done ) {
748748 var app = express ( )
749749
750- app . get ( '/user/: user+ ' , function ( req , res ) {
750+ app . get ( '/user/* user' , function ( req , res ) {
751751 res . end ( req . params . user )
752752 } )
753753
@@ -781,7 +781,7 @@ describe('app.router', function(){
781781 var app = express ( ) ;
782782 var cb = after ( 2 , done )
783783
784- app . get ( '/:name.:format? ' , function ( req , res ) {
784+ app . get ( '/:name{ .:format} ' , function ( req , res ) {
785785 res . end ( req . params . name + ' as ' + ( req . params . format || 'html' ) ) ;
786786 } ) ;
787787
@@ -800,7 +800,7 @@ describe('app.router', function(){
800800 var app = express ( )
801801 , calls = [ ] ;
802802
803- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
803+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
804804 calls . push ( '/foo/:bar?' ) ;
805805 next ( ) ;
806806 } ) ;
@@ -885,7 +885,7 @@ describe('app.router', function(){
885885 var app = express ( )
886886 , calls = [ ] ;
887887
888- app . get ( '/foo/:bar? ' , function ( req , res , next ) {
888+ app . get ( '/foo{ /:bar} ' , function ( req , res , next ) {
889889 calls . push ( '/foo/:bar?' ) ;
890890 next ( ) ;
891891 } ) ;
@@ -1096,7 +1096,7 @@ describe('app.router', function(){
10961096 var app = express ( ) ;
10971097 var path = [ ] ;
10981098
1099- app . get ( '/: path+ ' , function ( req , res , next ) {
1099+ app . get ( '/* path' , function ( req , res , next ) {
11001100 path . push ( 0 ) ;
11011101 next ( ) ;
11021102 } ) ;
@@ -1116,7 +1116,7 @@ describe('app.router', function(){
11161116 next ( ) ;
11171117 } ) ;
11181118
1119- app . get ( '/(.*) ' , function ( req , res , next ) {
1119+ app . get ( '/*splat ' , function ( req , res , next ) {
11201120 path . push ( 4 ) ;
11211121 next ( ) ;
11221122 } ) ;
0 commit comments