-
Notifications
You must be signed in to change notification settings - Fork 11
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
Route matching order #14
Comments
Hi @lukesargeant , glad it's working out for you. This behaviour of later routes overriding earlier ones is by design and meant to mimic
It's done this way in an attempt to introduce as little convention as possible - where that is feasible. Let me know if you think there's reason to do it the other way around. |
Hi @biril , I'd like my 'fauxServer' to be as close to the actual server as possible. All route matching libraries I've used in the past have done it 'first match wins' style, and so I had assumed this was the convention. I think that line from the Backbone docs refers to overriding an existing route with a new handler, rather than the new route winning due to it being declared later, but I haven't tested this. It's perhaps just a bit more of a usual pattern whether writing a case statement or an if, else if, or a loop that breaks or a functional loop that returns early...they all tend to pick the first match. This also helps performance a bit. |
Also it might be useful to know... I'm not actually using backbone's router in my later projects as it doesn't really play a part in synchronising my Models/collections to a Restful server. |
Hi, love the plugin!
Conventionally when you give a router a set of urls to match it's a case of first one wins. I am assigning handlers to the following routes:
users/me
users/:id
In the case of backbone requesting users/me the users/:id route is winning.
Reversing the handler definitions does the trick but in my experience the first matched route is usually supposed to handle the request.
The text was updated successfully, but these errors were encountered: