-
Notifications
You must be signed in to change notification settings - Fork 3k
Ensuring stable sort of route rules used for matching URLs. #2502
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,31 @@ describe("UrlRouter", function () { | |
match = ['/foo/bar', $match]; | ||
}).when('/bar', function($match) { | ||
match = ['/bar', $match]; | ||
}); | ||
}).when('/', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
match = '/home'; | ||
}).when('/abc', function() { | ||
match = '/abc/step1'; | ||
}).when('/abc', function() { | ||
match = '/abc/step2'; | ||
}).when('/defg', function() { | ||
match = '/defg'; | ||
}).when('/hij', function() { | ||
match = '/hij/step1'; | ||
}).when('/hij', function() { | ||
match = '/hij/step2'; | ||
}).when('/hij', function() { | ||
match = '/hij/step3'; | ||
}).when('/hij', function() { | ||
match = '/hij/step4'; | ||
}).when('/klmno', function() { | ||
match = '/klmno/step1'; | ||
}).when('/klmno', function() { | ||
match = '/klmno/step2'; | ||
}).when('/pqr', function() { | ||
match = '/pqr/step1'; | ||
}).when('/pqr', function() { | ||
match = '/pqr/step2';} | ||
); | ||
}); | ||
|
||
module('ui.router.router', 'ui.router.router.test'); | ||
|
@@ -84,6 +108,12 @@ describe("UrlRouter", function () { | |
expect(match[0]).toBe("/foo/:param"); | ||
expect(match[1]).toEqual({param: 'baz'}); | ||
}); | ||
|
||
it('should default to the first rule defined for same url', function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test always passed in PhantomJs, but when run in Chrome ( |
||
location.path('/hij'); | ||
scope.$emit('$locationChangeSuccess'); | ||
expect(match).toBe('/hij/step1'); | ||
}); | ||
|
||
it("should execute rewrite rules", function () { | ||
location.path("/foo"); | ||
|
@@ -261,4 +291,4 @@ describe("UrlRouter", function () { | |
}); | ||
}); | ||
|
||
}); | ||
}); |
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.
Ensures a stable sort in Chrome browsers