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:
parent
f356d03362
commit
c9cec60007
@ -43,7 +43,7 @@ export class RouteRecognizer {
|
|||||||
StringMapWrapper.set(solution, 'params', pathRecognizer.parseParams(url));
|
StringMapWrapper.set(solution, 'params', pathRecognizer.parseParams(url));
|
||||||
|
|
||||||
//TODO(btford): determine a good generic way to deal with terminal matches
|
//TODO(btford): determine a good generic way to deal with terminal matches
|
||||||
if (url === '/') {
|
if (url == '/') {
|
||||||
StringMapWrapper.set(solution, 'matchedUrl', '/');
|
StringMapWrapper.set(solution, 'matchedUrl', '/');
|
||||||
StringMapWrapper.set(solution, 'unmatchedUrl', '');
|
StringMapWrapper.set(solution, 'unmatchedUrl', '');
|
||||||
} else {
|
} else {
|
||||||
|
@ -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', () => {
|
it('should work with a dynamic segment', () => {
|
||||||
recognizer.addConfig('/user/:name', handler);
|
recognizer.addConfig('/user/:name', handler);
|
||||||
expect(recognizer.recognize('/user/brian')[0]).toEqual({
|
expect(recognizer.recognize('/user/brian')[0]).toEqual({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user