Skip to content

Commit

Permalink
fix(matcher): correct check when removing existing records on add
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 25, 2020
1 parent dfc1fb3 commit 2c267f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/matcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit 2c267f5

Please sign in to comment.