File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -367,18 +367,27 @@ function replaceBackslash(s?: string) {
367367 return s ?. replace ( / \\ / gi, '/' )
368368}
369369
370- function hasParentRoute ( routes : RouteNode [ ] , routeToCheck : string | undefined ) : RouteNode | null {
370+ export function hasParentRoute ( routes : RouteNode [ ] , routeToCheck : string | undefined ) : RouteNode | null {
371371 if ( ! routeToCheck || routeToCheck === "/" ) {
372372 return null ;
373373 }
374- for ( const route of routes ) {
374+
375+ const sortedNodes = multiSortBy ( routes , [
376+ ( d ) => d . routePath ! . length * - 1 ,
377+ ( d ) => d . variableName ,
378+
379+ ] ) . filter ( ( d ) => d . routePath !== `/${ rootPathId } ` )
380+
381+ for ( const route of sortedNodes ) {
375382 if ( route . routePath === '/' ) continue ;
383+
376384 if ( routeToCheck . startsWith ( `${ route . routePath } /` ) && route . routePath !== routeToCheck ) {
377385 return route ;
378386 }
379387 }
380388 const segments = routeToCheck . split ( "/" ) ;
381389 segments . pop ( ) ; // Remove the last segment
382390 const parentRoute = segments . join ( "/" ) ;
391+
383392 return hasParentRoute ( routes , parentRoute ) ;
384393}
You can’t perform that action at this time.
0 commit comments