Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace existing route in addRoute show warning msg #3519

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/create-route-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ function addRouteRecord (

if (!pathMap[record.path]) {
pathList.push(record.path)
pathMap[record.path] = record
}
pathMap[record.path] = record
Copy link

@rwaltenberg rwaltenberg Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is undocumented behavior. The documentation states that only if the route has a name and the name matches with an existing route, it should be overwritten.


if (route.alias !== undefined) {
const aliases = Array.isArray(route.alias) ? route.alias : [route.alias]
Expand Down Expand Up @@ -178,9 +178,8 @@ function addRouteRecord (
}

if (name) {
if (!nameMap[name]) {
nameMap[name] = record
} else if (process.env.NODE_ENV !== 'production' && !matchAs) {
nameMap[name] = record
if (!nameMap[name] && process.env.NODE_ENV !== 'production' && !matchAs) {
warn(
false,
`Duplicate named routes definition: ` +
Expand Down