Skip to content

Commit b264be4

Browse files
revert: fix(Angular.js): toKeyValue is not serializing null values
This commit contained broken tests and was not ready to be merged. (reverted from commit 814c984)
1 parent 814c984 commit b264be4

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

src/Angular.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1062,16 +1062,14 @@ function parseKeyValue(/**string*/keyValue) {
10621062
function toKeyValue(obj) {
10631063
var parts = [];
10641064
forEach(obj, function(value, key) {
1065-
if (value !== null) {
1066-
if (isArray(value)) {
1067-
forEach(value, function(arrayValue) {
1068-
parts.push(encodeUriQuery(key, true) +
1069-
(arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));
1070-
});
1071-
} else {
1065+
if (isArray(value)) {
1066+
forEach(value, function(arrayValue) {
10721067
parts.push(encodeUriQuery(key, true) +
1073-
(value === true ? '' : '=' + encodeUriQuery(value, true)));
1074-
}
1068+
(arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));
1069+
});
1070+
} else {
1071+
parts.push(encodeUriQuery(key, true) +
1072+
(value === true ? '' : '=' + encodeUriQuery(value, true)));
10751073
}
10761074
});
10771075
return parts.length ? parts.join('&') : '';

test/AngularSpec.js

-8
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,6 @@ describe('angular', function() {
491491
expect(toKeyValue({key: [323,'value',true, 1234]})).
492492
toEqual('key=323&key=value&key&key=1234');
493493
});
494-
495-
it('should not serialize null values', function() {
496-
expect(toKeyValue({nullKey: null, key: 'value'})).toEqual('key=value');
497-
});
498-
499-
it('should not serialize undefined', function() {
500-
expect(toKeyValue({undefinedKey: undefined, key: 'value'})).toEqual('key=value');
501-
});
502494
});
503495

504496

0 commit comments

Comments
 (0)