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

Commit a8a750a

Browse files
committed
feat($http): make the transform defaults to an array
$httpProvider.defaults.transformRequest and $httpProvider.defaults.transformResponse are now arrays containing single function. This makes it easy to add an extra transform fn. adding an extra fn before had to be done in this cluncky way: $httpProvider.defaults.transformResponse = [$httpProvider.defaults.transformResponse, myTransformFn]; after this change, it's simply: $httpProvider.defaults.transformResponse.push(myTransformFn);
1 parent 13a95ae commit a8a750a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/ng/http.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ function $HttpProvider() {
9090

9191
var $config = this.defaults = {
9292
// transform incoming response data
93-
transformResponse: function(data) {
93+
transformResponse: [function(data) {
9494
if (isString(data)) {
9595
// strip json vulnerability protection prefix
9696
data = data.replace(PROTECTION_PREFIX, '');
9797
if (JSON_START.test(data) && JSON_END.test(data))
9898
data = fromJson(data, true);
9999
}
100100
return data;
101-
},
101+
}],
102102

103103
// transform outgoing request data
104-
transformRequest: function(d) {
104+
transformRequest: [function(d) {
105105
return isObject(d) && !isFile(d) ? toJson(d) : d;
106-
},
106+
}],
107107

108108
// default headers
109109
headers: {

0 commit comments

Comments
 (0)