Skip to content

Commit

Permalink
fix($httpParamSerializer): ignore functions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlfranz authored and gkalpak committed Jul 31, 2017
1 parent f1d01bb commit 394dbcc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function $HttpParamSerializerProvider() {
if (!params) return '';
var parts = [];
forEachSorted(params, function(value, key) {
if (value === null || isUndefined(value)) return;
if (value === null || isUndefined(value) || isFunction(value)) return;
if (isArray(value)) {
forEach(value, function(v) {
parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));
Expand Down
5 changes: 4 additions & 1 deletion test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2344,14 +2344,17 @@ describe('$http param serializers', function() {
expect(defSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z');
expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z');
});

});

describe('default array serialization', function() {

it('should serialize arrays by repeating param name', function() {
expect(defSer({a: 'b', foo: ['bar', 'baz']})).toEqual('a=b&foo=bar&foo=baz');
});

it('should NOT serialize functions', function() {
expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov');
});
});

describe('jquery array and objects serialization', function() {
Expand Down

0 comments on commit 394dbcc

Please sign in to comment.