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

fix($http): add check for functions in request #16133

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2345,6 +2345,10 @@ describe('$http param serializers', function() {
expect(jqrSer({someDate: new Date('2014-07-15T17:30:00.000Z')})).toEqual('someDate=2014-07-15T17:30:00.000Z');
});

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not common functionality. It does not belong here, but in default array serialization section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved!


});

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