-
Notifications
You must be signed in to change notification settings - Fork 86
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
Build up specificity for nested routes. #103
Conversation
@tjni you are on the right track here. Specificity of a previously added route was being stomped by a second route, and using an object as a bucket avoids the stomping. However I'm not sure this restores all the functionality we need (there are definitely two tests I have added that do not pass with it) however this is a step in the right direction. |
@tjni this seems an incremental fix, but fails on the following assertion: test("Matches the route with the longer static prefix with nesting", function() {
var handler1 = { handler: 1 };
var handler2 = { handler: 2 };
var router = new RouteRecognizer();
router.add([{ path: "/", handler: handler1 }, { path: ":post_id", handler: handler1 }]);
router.add([{ path: "/team", handler: handler2 }, { path: ":user_slug", handler: handler2 }]);
resultsMatch(router.recognize("/team"), [
{ handler: handler2, params: { }, isDynamic: false },
{ handler: handler2, params: { }, isDynamic: false }
]);
}); Which I believe is appropriate to assert emberjs/ember.js#13960 is fixed. |
Planning on looking into this in a few hours in the evening, unless someone else is already. |
@tjni in fact the test you've added here already passes on master, I believe. |
scratch that, my test does not pass in 0.1.5 either. I must have incorrect ported emberjs/ember.js#13960 |
@tjni I've confirmed you fix with this test: https://github.com/tildeio/route-recognizer/pull/105/files#diff-d4ce617de337dd77d23737176f335d8cR884 Please add it to this PR! I believe that will give us the option for moving forward with this change instead of reverting. |
Route specificity was being limited to only that of the last segment. This was incorrect causing some regressions in Ember. Original PR at: tildeio#103
When adding an array of routes, each route will increase the specificity instead of using only that of the last route.
LGTM |
@@ -151,8 +148,6 @@ function parse(route, names, specificity, shouldDecodes) { | |||
} | |||
} | |||
|
|||
specificity.val = +specificity.val; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unnecessary type conversion which is why it was removed.
@mixonic It turns out we did need to land the test from #85. I've extracted exactly the routes generated from emberjs/ember.js#14073 and we trigger the same failure as the test from #85. Here is what Ember generates to feed into route-recognizer:
The adjacent epsilon segments break things. |
When adding an array of routes, each route will increase the
specificity instead of using only that of the last route.
Resolves #102.