Permalink
Browse files

fix ignoring of null / undefined. Closes #44

  • Loading branch information...
1 parent 66d9131 commit 19fee0b5b2d22974d824d77d35011b96f91e361c @tj committed Mar 15, 2013
Showing with 3 additions and 1 deletion.
  1. +1 −0 index.js
  2. +2 −1 test/stringify.js
View
@@ -195,6 +195,7 @@ function stringifyObject(obj, prefix) {
for (var i = 0, len = keys.length; i < len; ++i) {
key = keys[i];
+ if (null == obj[key]) continue;
ret.push(stringify(obj[key], prefix
? prefix + '[' + encodeURIComponent(key) + ']'
: encodeURIComponent(key)));
View
@@ -16,7 +16,8 @@ var str_identities = {
{ str: 'foo=1&bar=2', obj: {'foo' : '1', 'bar' : '2'}},
{ str: 'my%20weird%20field=q1!2%22\'w%245%267%2Fz8)%3F', obj: {'my weird field': "q1!2\"'w$5&7/z8)?"}},
{ str: 'foo%3Dbaz=bar', obj: {'foo=baz': 'bar'}},
- { str: 'foo=bar&bar=baz', obj: {foo: 'bar', bar: 'baz'}}
+ { str: 'foo=bar&bar=baz', obj: {foo: 'bar', bar: 'baz'}},
+ { str: 'foo=bar', obj: { foo: 'bar', baz: null, raz: undefined }}
],
'escaping': [
{ str: 'foo=foo%20bar', obj: {foo: 'foo bar'}},

1 comment on commit 19fee0b

@mikeal
mikeal commented on 19fee0b Mar 15, 2013

awesome, updated request.

Please sign in to comment.