Skip to content

Commit 515bfcf

Browse files
committed
fix(core): Make flattenRoutePath return a valid module
flattenRoutePath method was returning an object instead of a module when path property was an empty string closes #15332
1 parent 84d0ff3 commit 515bfcf

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/core/router/utils/flatten-route-paths.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function flattenRoutePaths(routes: Routes) {
1414
if (item.children) {
1515
const childrenRef = item.children as Routes;
1616
childrenRef.forEach(child => {
17-
if (!isString(child) && child.path) {
17+
if (!isString(child) && isString(child.path)) {
1818
child.path = normalizePath(
1919
normalizePath(item.path) + normalizePath(child.path),
2020
);

packages/core/test/router/utils/flat-routes.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ describe('flattenRoutePaths', () => {
1717
@Module({})
1818
class ChildModule4 {}
1919
@Module({})
20+
class ChildModule5 {}
21+
@Module({})
22+
class ChildParentPathModule {}
23+
@Module({})
2024
class ParentChildModule {}
2125
@Module({})
2226
class ChildChildModule2 {}
@@ -70,6 +74,16 @@ describe('flattenRoutePaths', () => {
7074
ChildModule4,
7175
],
7276
},
77+
{
78+
path: 'child3',
79+
children: [
80+
{
81+
path: '',
82+
module: ChildModule5,
83+
children: [{ path: 'child', module: ChildParentPathModule }],
84+
},
85+
],
86+
},
7387
],
7488
},
7589
{ path: '/v1', children: [AuthModule, CatsModule, DogsModule] },
@@ -91,6 +105,8 @@ describe('flattenRoutePaths', () => {
91105
},
92106
{ path: '/parent/child2', module: ChildModule4 },
93107
{ path: '/parent/child2/child', module: ChildModule3 },
108+
{ path: '/parent/child3', module: ChildModule5 },
109+
{ path: '/parent/child3/child', module: ChildParentPathModule },
94110
{ path: '/v1', module: AuthModule },
95111
{ path: '/v1', module: CatsModule },
96112
{ path: '/v1', module: DogsModule },

0 commit comments

Comments
 (0)