File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,11 @@ export default class RouteNode {
4545 return this ;
4646 }
4747
48+ setPath ( path = '' ) {
49+ this . path = path ;
50+ this . parser = path ? new Path ( path ) : null ;
51+ }
52+
4853 add ( route , cb = noop ) {
4954 let originalRoute ;
5055 if ( route === undefined || route === null ) return ;
Original file line number Diff line number Diff line change @@ -357,6 +357,17 @@ describe('RouteNode', function () {
357357 node . buildPath ( 'route' , { b : '2' } ) . should . equal ( '/path?b=2' ) ;
358358 node . buildPath ( 'route' , { a : '1' , b : '2' } ) . should . equal ( '/path?a=1&b=2' ) ;
359359 } ) ;
360+
361+ it ( 'should be able to modify a path' , function ( ) {
362+ var node = new RouteNode ( '' , '' , [
363+ new RouteNode ( 'route' , '/path' )
364+ ] ) ;
365+
366+ node . buildPath ( 'route' ) . should . equal ( '/path' ) ;
367+ node . buildPath ( 'route' , { param : '1' } ) . should . equal ( '/path' ) ;
368+ node . setPath ( '?param' ) ;
369+ node . buildPath ( 'route' , { param : '1' } ) . should . equal ( '/path?param=1' ) ;
370+ } ) ;
360371} ) ;
361372
362373
You can’t perform that action at this time.
0 commit comments