-
Notifications
You must be signed in to change notification settings - Fork 7.3k
querystring.stringify behavior for undefined, null, empty array[], should be improved #7971
Comments
I disagree that empty array is broken. It should display I do agree with you that |
@cjihrig Yes, it does that (display for every value in the array). The case I'm referring to is where the array is empty. See my example which has Here's an example which may illustrate it clearer:
|
Ah yes, the ampersand definitely shouldn't be displayed if nothing else is. |
@indutny any comment on the other behavior ? |
@danielb2 I don't think that the rest are the bugs. |
@indutny it seems suspicious that even keys that are Are you sure? The behavior does makes sense for null, but not undefined as well |
I've often thought that If you really want to pass a query string that equals the value "undefined" you shouldn't rely on the side effect of There is already precedent for this behavior with |
A |
I agree with This seems wrong to me: var qs = require('querystring')
var obj = {
foo : undefined
};
obj.bar === undefined;
obj.foo === undefined;
obj = qs.parse(qs.stringify(obj));
obj.bar === undefined;
// however...
obj.foo !== undefined; Also differing from |
@indutny ping? |
My 2c: we should aim to make |
Currently we see
Empty array appears to be broken, and should, I believe, return:
lonelyAmpersand=
I think at least undefined should exclude the item from showing up at all as both null and empty string cover that already. IOW, I would have expected
stringify({ blah: undefined })
to return''
Thoughts?
The text was updated successfully, but these errors were encountered: