vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.91k stars 1.19k forks source link

Wrong routing with routes with same name but different path #1930

Closed MarcelFinkbeiner closed 1 year ago

MarcelFinkbeiner commented 1 year ago

Reproduction

https://codesandbox.io/s/testing-named-vue-router-bug-forked-r7zd5p

Steps to reproduce the bug

click on /network button is working but the /network/WIFI/NONE button is getting catched and redirected.

Expected behavior

The optional parameter name should not cause this behavior at least not without any warning/error

Actual behavior

The correct route is getting catched without any information why

Additional information

No response

posva commented 1 year ago

You have duplicated names. They must be unique

MarcelFinkbeiner commented 1 year ago

Yes @posva you are right. The point is that there is no warning and I think for a optional parameter that can break the whole navigation there should be at least a warning that there are duplicate names. Also it is not mentioned in the docs: https://router.vuejs.org/guide/essentials/named-routes.html. And it is called name like in name it to have a better overview and not an id/key as in id must be unique.

MarcelFinkbeiner commented 1 year ago

Nice thank you!