@@ -48,6 +48,14 @@ var routes = {
48
48
array_path : {
49
49
path : [ '/array_path' ]
50
50
} ,
51
+ array_path_name_collision : {
52
+ path : [
53
+ '/array/path/with/collision/foo/:key' ,
54
+ '/array/path/with/collision/bar/:key'
55
+ ] ,
56
+ method : 'GET' ,
57
+ page : 'arrayPathNameCollision'
58
+ } ,
51
59
invalid_path : {
52
60
path : 123
53
61
}
@@ -61,7 +69,7 @@ describe('Router', function () {
61
69
62
70
describe ( '#constructor' , function ( ) {
63
71
it ( 'should init correctly' , function ( ) {
64
- expect ( Object . keys ( router . _routes ) . length ) . to . equal ( 9 ) ;
72
+ expect ( Object . keys ( router . _routes ) . length ) . to . equal ( 10 ) ;
65
73
66
74
expect ( router . _routes . article . name ) . to . equal ( 'article' ) ;
67
75
expect ( router . _routes . article . config . path ) . to . equal ( '/:site/:category?/:subcategory?/:alias' ) ;
@@ -120,10 +128,10 @@ describe('Router', function () {
120
128
process . env . NODE_ENV = 'production' ;
121
129
var notFrozen = new Router ( routes ) ;
122
130
123
- expect ( Object . keys ( notFrozen . _routes ) . length ) . to . equal ( 9 ) ;
131
+ expect ( Object . keys ( notFrozen . _routes ) . length ) . to . equal ( 10 ) ;
124
132
notFrozen . _routes . foo = null ;
125
133
expect ( notFrozen . _routes . foo ) . to . equal ( null ) ;
126
- expect ( Object . keys ( notFrozen . _routes ) . length ) . to . equal ( 10 ) ;
134
+ expect ( Object . keys ( notFrozen . _routes ) . length ) . to . equal ( 11 ) ;
127
135
128
136
var homeRoute = notFrozen . _routes . home ;
129
137
expect ( homeRoute . name ) . to . equal ( 'home' ) ;
@@ -136,7 +144,7 @@ describe('Router', function () {
136
144
process . env . NODE_ENV = 'development' ;
137
145
var frozen = new Router ( routes ) ;
138
146
var homeRoute = frozen . _routes . home ;
139
- expect ( Object . keys ( frozen . _routes ) . length ) . to . equal ( 9 ) ;
147
+ expect ( Object . keys ( frozen . _routes ) . length ) . to . equal ( 10 ) ;
140
148
expect ( homeRoute . name ) . to . equal ( 'home' ) ;
141
149
expect ( homeRoute . config . path ) . to . equal ( '/' ) ;
142
150
expect ( homeRoute . config . method ) . to . equal ( 'get' ) ;
@@ -161,7 +169,7 @@ describe('Router', function () {
161
169
expect ( function ( ) {
162
170
homeRoute . config . regexp = null ;
163
171
} ) . to . throw ( TypeError ) ;
164
- expect ( Object . keys ( frozen . _routes ) . length ) . to . equal ( 9 ) ;
172
+ expect ( Object . keys ( frozen . _routes ) . length ) . to . equal ( 10 ) ;
165
173
expect ( frozen . _routes . foo ) . to . equal ( undefined ) ;
166
174
expect ( homeRoute . keys . length ) . to . equal ( 0 ) ;
167
175
expect ( homeRoute . name ) . to . equal ( 'home' ) ;
@@ -254,6 +262,15 @@ describe('Router', function () {
254
262
route = router . getRoute ( '/new_article' , 'delete' ) ;
255
263
expect ( route ) . to . equal ( null ) ;
256
264
} ) ;
265
+ it ( 'array route with param name collision first' , function ( ) {
266
+ var route = router . getRoute ( '/array/path/with/collision/foo/abc' ) ;
267
+ expect ( route . params . key ) . to . equal ( 'abc' ) ;
268
+ } ) ;
269
+ it ( 'array route with param name collision second' , function ( ) {
270
+ var route = router . getRoute ( '/array/path/with/collision/bar/abc' ) ;
271
+ expect ( route . params . key ) . to . equal ( 'abc' ) ;
272
+ } ) ;
273
+
257
274
} ) ;
258
275
259
276
describe ( '#makePath' , function ( ) {
0 commit comments