Skip to content

Commit cf0b038

Browse files
extemplshockey
authored andcommitted
improvement: use JSON.parse method for all types and encodings of json (via #1419)
* Use `JSON.parse` method for all types and encodings of `json` * Fix case when `contentType` is `undefined`
1 parent 6e55915 commit cf0b038

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export default async function http(url, request = {}) {
6969
export const shouldDownloadAsText = (contentType = '') => /(json|xml|yaml|text)\b/.test(contentType)
7070

7171
function parseBody(body, contentType) {
72-
if (contentType === 'application/json') {
72+
if (contentType && (contentType.indexOf('application/json') === 0 || contentType.indexOf('+json') > 0)) {
7373
return JSON.parse(body)
7474
}
7575
return jsYaml.safeLoad(body)

0 commit comments

Comments
 (0)