core-api/routing: allow duplicate registration if paths match
This commit is contained in:
@@ -44,6 +44,7 @@ describe('RouteRefRegistry', () => {
|
||||
expect(registry.registerRoute([ref1, ref12], 'duplicate')).toBe(false);
|
||||
expect(registry.registerRoute([ref2], '2')).toBe(true);
|
||||
expect(registry.registerRoute([ref2], 'duplicate')).toBe(false);
|
||||
expect(registry.registerRoute([ref2], '2')).toBe(true);
|
||||
|
||||
expect(registry.resolveRoute([], [ref1])).toBe('/1');
|
||||
expect(registry.resolveRoute([], [ref11])).toBe(undefined);
|
||||
|
||||
@@ -68,8 +68,10 @@ class Node {
|
||||
|
||||
const lastRoute = routes[routes.length - 1];
|
||||
const lastRouteRef = lastRoute[routeReference];
|
||||
if (parentNode.children.has(lastRouteRef)) {
|
||||
return false;
|
||||
|
||||
const existingNode = parentNode.children.get(lastRouteRef);
|
||||
if (existingNode) {
|
||||
return existingNode.path === path;
|
||||
}
|
||||
|
||||
parentNode.children.set(lastRouteRef, new Node(path, parentNode));
|
||||
|
||||
Reference in New Issue
Block a user