diff --git a/js/libtextsecure.js b/js/libtextsecure.js index fa5d03ea0f..59af9145e6 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -37501,12 +37501,13 @@ var TextSecureServer = (function() { } window.nodeFetch(url, fetchOptions).then(function(response) { var resultPromise; - if (options.responseType === 'json') { + if (options.responseType === 'json' + && response.headers.get('Content-Type') === 'application/json') { resultPromise = response.json(); - } else if (!options.responseType || options.responseType === 'text') { - resultPromise = response.text(); } else if (options.responseType === 'arraybuffer') { resultPromise = response.buffer(); + } else { + resultPromise = response.text(); } return resultPromise.then(function(result) { if (options.responseType === 'arraybuffer') { diff --git a/libtextsecure/api.js b/libtextsecure/api.js index 0c20d84167..aa8ee2c039 100644 --- a/libtextsecure/api.js +++ b/libtextsecure/api.js @@ -64,12 +64,13 @@ var TextSecureServer = (function() { } window.nodeFetch(url, fetchOptions).then(function(response) { var resultPromise; - if (options.responseType === 'json') { + if (options.responseType === 'json' + && response.headers.get('Content-Type') === 'application/json') { resultPromise = response.json(); - } else if (!options.responseType || options.responseType === 'text') { - resultPromise = response.text(); } else if (options.responseType === 'arraybuffer') { resultPromise = response.buffer(); + } else { + resultPromise = response.text(); } return resultPromise.then(function(result) { if (options.responseType === 'arraybuffer') {