File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -263,12 +263,17 @@ const init = config => {
263
263
}
264
264
}
265
265
config . routes . forEach ( item => {
266
- const path = item . path
267
- if ( path . lastIndexOf ( '?' ) !== - 1 ) {
266
+ let path = item . path
267
+ // Pattern to identify the last path of the route
268
+ // It should start with "/:" + any word and ends with "?"
269
+ // Example /player/:asset/:assetId?
270
+ const pattern = / \/ : { 1 } \w + \? $ /
271
+ if ( pattern . test ( item . path ) ) {
268
272
const optionalPath = path . substring ( 0 , path . lastIndexOf ( '/' ) )
269
- item . path = path . substring ( 0 , path . lastIndexOf ( '?' ) )
273
+ const originalPath = path . substring ( 0 , path . lastIndexOf ( '?' ) )
274
+ item . path = originalPath
270
275
//Create another entry with the optional path
271
- const optionalItem = { ...item }
276
+ let optionalItem = { ...item }
272
277
optionalItem . path = optionalPath
273
278
config . routes . push ( optionalItem )
274
279
}
You can’t perform that action at this time.
0 commit comments