@@ -24,7 +24,7 @@ var RouteNode = (function () {
2424
2525 this . name = name ;
2626 this . path = path ;
27- this . parser = path ? new _pathParser2 [ 'default' ] ( path ) : { } ;
27+ this . parser = path ? new _pathParser2 [ 'default' ] ( path ) : null ;
2828 this . children = [ ] ;
2929
3030 this . add ( childRoutes ) ;
@@ -96,11 +96,11 @@ var RouteNode = (function () {
9696 return matched ? segments : false ;
9797 }
9898 } , {
99- key : 'getSegmentsByPath ' ,
100- value : function getSegmentsByPath ( path ) {
101- var matchChildren = function matchChildren ( node , pathSegment , segments ) {
99+ key : 'getSegmentsMatchingPath ' ,
100+ value : function getSegmentsMatchingPath ( path ) {
101+ var matchChildren = function matchChildren ( nodes , pathSegment , segments ) {
102102 var _loop = function ( i ) {
103- var child = node . children [ i ] ;
103+ var child = nodes [ i ] ;
104104 // Partially match path
105105 var match = child . parser . partialMatch ( pathSegment ) ;
106106 if ( match ) {
@@ -124,24 +124,25 @@ var RouteNode = (function () {
124124 }
125125 // Else: remaining path and children
126126 return {
127- v : matchChildren ( child , remainingPath , segments )
127+ v : matchChildren ( child . children , remainingPath , segments )
128128 } ;
129129 }
130130 } ;
131131
132132 // for (child of node.children) {
133- for ( var i in node . children ) {
133+ for ( var i in nodes ) {
134134 var _ret = _loop ( i ) ;
135135
136136 if ( typeof _ret === 'object' ) return _ret . v ;
137137 }
138138 return false ;
139139 } ;
140140
141+ var startingNodes = this . parser ? [ this ] : this . children ;
141142 var segments = [ ] ;
142143 segments . params = { } ;
143144
144- return matchChildren ( this , path , segments ) ;
145+ return matchChildren ( startingNodes , path , segments ) ;
145146 }
146147 } , {
147148 key : 'getPath' ,
@@ -166,7 +167,7 @@ var RouteNode = (function () {
166167 } , {
167168 key : 'matchPath' ,
168169 value : function matchPath ( path ) {
169- var segments = this . getSegmentsByPath ( path ) ;
170+ var segments = this . getSegmentsMatchingPath ( path ) ;
170171
171172 if ( ! segments ) return false ;
172173
0 commit comments