From f3dcdd778b98bb4d415eea339c1019feac856236 Mon Sep 17 00:00:00 2001 From: Nate Hunzaker Date: Sat, 28 Jun 2014 12:42:22 -0400 Subject: [PATCH] [fixed] injectParams invariant should not throw on values that coerce to false. --- modules/helpers/Path.js | 2 +- specs/Path.spec.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/helpers/Path.js b/modules/helpers/Path.js index 6d13a2dbff..deefa95c7b 100644 --- a/modules/helpers/Path.js +++ b/modules/helpers/Path.js @@ -85,7 +85,7 @@ var Path = { var paramName = getParamName(pathSegment); invariant( - params[paramName], + params[paramName] != null, 'Missing "' + paramName + '" parameter for path "' + pattern + '"' ); diff --git a/specs/Path.spec.js b/specs/Path.spec.js index ceaf2b6a1a..0c2bf6ca7d 100644 --- a/specs/Path.spec.js +++ b/specs/Path.spec.js @@ -127,6 +127,10 @@ describe('Path.injectParams', function () { it('returns the correct path', function () { expect(Path.injectParams(pattern, { id: 'abc' })).toEqual('comments/abc/edit'); }); + + it('returns the correct path when the value is 0', function () { + expect(Path.injectParams(pattern, { id: 0 })).toEqual('comments/0/edit'); + }); }); describe('and some params have special URL encoding', function () {