Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 394dbcc

Browse files
carlfranzgkalpak
authored andcommitted
fix($httpParamSerializer): ignore functions
Closes #16133
1 parent f1d01bb commit 394dbcc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/ng/http.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function $HttpParamSerializerProvider() {
4141
if (!params) return '';
4242
var parts = [];
4343
forEachSorted(params, function(value, key) {
44-
if (value === null || isUndefined(value)) return;
44+
if (value === null || isUndefined(value) || isFunction(value)) return;
4545
if (isArray(value)) {
4646
forEach(value, function(v) {
4747
parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(serializeValue(v)));

test/ng/httpSpec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2344,14 +2344,17 @@ describe('$http param serializers', function() {
23442344
expect(defSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z');
23452345
expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z');
23462346
});
2347-
23482347
});
23492348

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

23522351
it('should serialize arrays by repeating param name', function() {
23532352
expect(defSer({a: 'b', foo: ['bar', 'baz']})).toEqual('a=b&foo=bar&foo=baz');
23542353
});
2354+
2355+
it('should NOT serialize functions', function() {
2356+
expect(defSer({foo: 'foov', bar: function() {}})).toEqual('foo=foov');
2357+
});
23552358
});
23562359

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

0 commit comments

Comments
 (0)