Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix ignoring of null / undefined. Closes #44

  • Loading branch information...
commit 19fee0b5b2d22974d824d77d35011b96f91e361c 1 parent 66d9131
TJ Holowaychuk authored
Showing with 3 additions and 1 deletion.
  1. +1 −0  index.js
  2. +2 −1  test/stringify.js
1  index.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)));
3  test/stringify.js
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 Rogers

awesome, updated request.

Please sign in to comment.
Something went wrong with that request. Please try again.