From 2c267f5aceec899c84514571e4fa75dc61441ed4 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 25 May 2020 10:17:21 +0200 Subject: [PATCH] fix(matcher): correct check when removing existing records on add --- src/matcher/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/matcher/index.ts b/src/matcher/index.ts index ab02038d..de894a29 100644 --- a/src/matcher/index.ts +++ b/src/matcher/index.ts @@ -118,6 +118,11 @@ export function createRouterMatcher( // otherwise, the first record is the original and others are aliases originalMatcher = originalMatcher || matcher if (originalMatcher !== matcher) originalMatcher.alias.push(matcher) + + // remove the route if named and only for the top record (avoid in nested calls) + // this works because the original record is the first one + if (isRootAdd && record.name && !isAliasRecord(matcher)) + removeRoute(record.name) } // only non redirect records have children @@ -136,9 +141,6 @@ export function createRouterMatcher( // other alias (if any) need to reference this record when adding children originalRecord = originalRecord || matcher - // remove the route if named and only for the top record (avoid in nested calls) - if (isRootAdd && record.name) removeRoute(record.name) - insertMatcher(matcher) } -- 2.47.3