Skip to content

Commit

Permalink
Fixing the getBody to only apply transform when body is a json (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michał Wójcik authored Aug 1, 2022
1 parent 7bb9b42 commit 2250292
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
method: 'GET',
transformResponse: function(defaults, transform) {
// Remove any comments from the body before deserializing
return JSON.parse(defaults.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, function (m, g) { return g ? "" : m }));
return transform()['content-type'] === 'text/json' ? JSON.parse(defaults.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, function (m, g) { return g ? "" : m })) : defaults;
}
});
}
Expand Down

0 comments on commit 2250292

Please sign in to comment.