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

Ensuring stable sort of route rules used for matching URLs. #2502

Closed
wants to merge 1 commit into from

Conversation

cdriscol
Copy link

This is the fix for #2501.

@@ -59,7 +59,31 @@ describe("UrlRouter", function () {
match = ['/foo/bar', $match];
}).when('/bar', function($match) {
match = ['/bar', $match];
});
}).when('/', function() {
Copy link
Author

Choose a reason for hiding this comment

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

These rule definitions may seem abundant - but it was the only way I could consistently reproduce the stable sorting issue in Chrome.

@nateabele
Copy link
Contributor

Wow, nice! Thanks for doing the research on this. We were just gonna roll back #1585, but this seems like a better solution for sure. /cc @christopherthielen

@@ -308,7 +309,8 @@ function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
rules.sort(function(ruleA, ruleB) {
var aLength = ruleA.prefix ? ruleA.prefix.length : 0;
var bLength = ruleB.prefix ? ruleB.prefix.length : 0;
return bLength - aLength;
var lengthDiff = bLength - aLength;
return lengthDiff !== 0 ? lengthDiff : ruleA.position - ruleB.position;
Copy link
Author

Choose a reason for hiding this comment

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

Ensures a stable sort in Chrome browsers

@christopherthielen
Copy link
Contributor

I really do like the idea of ordering the rules by specificity by default. We should definitely do that for 1.0.

My main concern with #1585 is that it's a legitimate breaking change from 0.2.15. For years we've told people that url rules are checked in the order that they were registered, and that they should re-order the registration of those rules if they need to change match priority.

Because sorting rules was a BC for 0.2.x, however, I think we should do one of three things for 0.2.18:

@nateabele
Copy link
Contributor

Yeah, fair enough. @cdriscol Update the PR to point to feature-1.0 and we'll merge it. @christopherthielen Yeah, fair enough. We'll just roll back #1585 for .18, merge this for 1.0, and implement sort strategies when we get time.

@chino23
Copy link

chino23 commented Feb 1, 2016

could this fix be released with a quick minor update soon?

@cdriscol
Copy link
Author

cdriscol commented Feb 1, 2016

@nateabele - I will get this into the feature-1.0 branch when I get some time in the next couple days.

will be good to get the sort rolled back in 0.2.18

@sebastiannm
Copy link

It would be good to release a new version for this soon. I found that it breaks a lot of stuff

@nateabele
Copy link
Contributor

@sebastiannm Yup, that's why it's going into 1.0 only, and the previous version is being rolled back.

@JetFault
Copy link

JetFault commented Feb 5, 2016

@nateabele When do ya think the 0.2.18 release will come out? Just noticed this broke my app so had to revert to .15

@nateabele
Copy link
Contributor

@JetFault Hard to say. We have this and one or two other BC breaks to patch up.

@cdriscol cdriscol closed this Feb 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants