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

Warn About Duplicate Route Names #366

Open
jods4 opened this issue Jul 6, 2016 · 9 comments
Open

Warn About Duplicate Route Names #366

jods4 opened this issue Jul 6, 2016 · 9 comments
Assignees
Milestone

Comments

@jods4
Copy link
Contributor

jods4 commented Jul 6, 2016

I have the following route definition:
{ route: 'location/:id', name: 'location' }

But when I call router.navigateToRoute('location', { id: 42 }) it navigates to: /location?id=42.

This does work for Aurelia, but it would be better if it went to the expected route: /location/42.
Other components (and users) might look at the URL and this is a bit unexpected.

@EisenbergEffect
Copy link
Contributor

It should work as you say, so there must be some sort of bug.

@jods4
Copy link
Contributor Author

jods4 commented Jul 6, 2016

Found the bug. It was in our code.

Someone created different routes for new and existing entities with the same name:

config.map([
  { router: 'location/:id', name: 'location', ... },
  { router: 'location', name: 'location', ... }
]);

It seems the last one wins, which then makes perfect sense.
I renamed the second route with name: 'newLocation' and now it works as it should, indeed.

Should there be at least a warning when you use the same name for different routes?

@jods4 jods4 closed this as completed Jul 6, 2016
@EisenbergEffect
Copy link
Contributor

Probably. We hadn't considered that sort of mistake :) We can certainly add it. Can you create a new issue for that? Also, this sounds like a great opportunity for a community PR :)

@jods4
Copy link
Contributor Author

jods4 commented Jul 6, 2016

@EisenbergEffect we can re-open this issue if you want to track the warning issue?

@EisenbergEffect EisenbergEffect changed the title Generate route should use route variables Warn About Duplicate Route Names Jul 6, 2016
@jods4
Copy link
Contributor Author

jods4 commented Jul 28, 2016

#377 has been merged and is published in 1.0.0 but it contains a critical bug!

Apparently, the patch #377 trips on single routes that have multiple alternative URLs.
So trying to register this route:
{ route: ['', 'home'], name: 'home' }
Triggers the distinct name error.

This is a very hard regression, because the impact is that the application does not start at all.

It is also a bit tricky to figure out, because the error message is clear, but doesn't say what route name is faulty... and when you look at your code, there is no duplicate names.

/cc @devanp92

@EisenbergEffect
Copy link
Contributor

It's already fixed. We realized it during the release process and reverted that code entirely.

@EisenbergEffect
Copy link
Contributor

Update to 1.0.2

@Alexander-Taran
Copy link
Contributor

can be closed.. maybe

@davismj davismj added this to the 2.0.0 milestone Feb 28, 2018
@davismj
Copy link
Member

davismj commented Feb 28, 2018

This is still an issue and a good one to track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants