From 1b23184861a4f779ba8919985ade5f16c56e22a1 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Tue, 30 Jun 2020 15:49:39 +0300 Subject: [PATCH] fix: do not include children in flat routes --- .../packages/core/src/lib/handlers/routes.handler.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/handlers/routes.handler.ts b/npm/ng-packs/packages/core/src/lib/handlers/routes.handler.ts index 637f7b4165..9ddc03e493 100644 --- a/npm/ng-packs/packages/core/src/lib/handlers/routes.handler.ts +++ b/npm/ng-packs/packages/core/src/lib/handlers/routes.handler.ts @@ -20,7 +20,7 @@ export class RoutesHandler { return; } - const routes = flatRoutes([{ ...data.routes, path }], { path: '' }); + const routes = flatRoutes([{ path, ...data.routes }], { path: '' }); this.routes.add(routes); }); } @@ -30,13 +30,13 @@ function flatRoutes(routes: RouteDef[], parent: any) { if (!routes) return []; return routes.reduce((acc, route) => { - const current = { + const { children, ...current } = { ...route, parentName: parent.name, - path: parent.path + '/' + route.path, + path: (parent.path + '/' + route.path).replace(/\/\//g, '/'), }; - acc.push(current, ...flatRoutes(current.children, current)); + acc.push(current, ...flatRoutes(children, current)); return acc; }, []);