fix(router): fix for leading slash in dart

Using string1 === string2 translates to identical(string1, string2) in
dart, which is incorrect as it is possilbe for dart strings to have
different reference.
This commit is contained in:
Rado Kirov 2015-05-05 15:19:06 -07:00
parent f356d03362
commit c9cec60007
2 changed files with 12 additions and 1 deletions

View File

@ -43,7 +43,7 @@ export class RouteRecognizer {
StringMapWrapper.set(solution, 'params', pathRecognizer.parseParams(url));
//TODO(btford): determine a good generic way to deal with terminal matches
if (url === '/') {
if (url == '/') {
StringMapWrapper.set(solution, 'matchedUrl', '/');
StringMapWrapper.set(solution, 'unmatchedUrl', '');
} else {

View File

@ -30,6 +30,17 @@ export function main() {
});
});
it('should work with leading slash', () => {
recognizer.addConfig('/', handler);
expect(recognizer.recognize('/')[0]).toEqual({
'handler': { 'components': { 'a': 'b' } },
'params': {},
'matchedUrl': '/',
'unmatchedUrl': ''
});
});
it('should work with a dynamic segment', () => {
recognizer.addConfig('/user/:name', handler);
expect(recognizer.recognize('/user/brian')[0]).toEqual({