Skip to content

Commit

Permalink
fix: strip Bom before parse to json
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr committed Jul 2, 2020
1 parent deb914d commit c522127
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/adapters/http.js
Expand Up @@ -235,14 +235,13 @@ module.exports = function httpAdapter(config) {
var responseData = Buffer.concat(responseBuffer);
if (config.responseType !== 'arraybuffer') {
responseData = responseData.toString(config.responseEncoding);
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
responseData = utils.stripBOM(responseData);
}
// only response type 'json' return JSON response, 'text' and '' return string response
if (config.responseType === 'json') {
responseData = utils.tryParseJSON(responseData);
}

if (!config.responseEncoding || config.responseEncoding === 'utf8') {
responseData = utils.stripBOM(responseData);
}
}

response.data = responseData;
Expand Down

0 comments on commit c522127

Please sign in to comment.