fix(router): fix incorrect url param value coercion of 1 to true

seriliazeParams is coercing a value of 1 to true, which causes the value to be completey dropped.
Change the test from double equals to triple equals to prevent this from happening.

Closes #5346

Closes #6286
This commit is contained in:
Brian Yarger 2016-01-05 22:34:10 -07:00 committed by Alex Eagle
parent b55f1764b5
commit 995a9e0cf8
2 changed files with 10 additions and 1 deletions

View File

@ -206,7 +206,7 @@ export function serializeParams(paramMap: {[key: string]: any}): string[] {
var params = [];
if (isPresent(paramMap)) {
StringMapWrapper.forEach(paramMap, (value, key) => {
if (value == true) {
if (value === true) {
params.push(key);
} else {
params.push(key + '=' + value);

View File

@ -220,6 +220,15 @@ export function main() {
expect(path).toEqual('hi/how/are/you?name=brad');
});
it('should preserve the number 1 as a query string value', () => {
router.config(
[new Route({path: '/hi/how/are/you', component: DummyComponent, name: 'GreetingUrl'})]);
var instruction = router.generate(['/GreetingUrl', {'name': 1}]);
var path = stringifyInstruction(instruction);
expect(path).toEqual('hi/how/are/you?name=1');
});
it('should serialize parameters that are not part of the route definition as query string params',
() => {
router.config([