fix: update isJSON test in request lib

This commit is contained in:
Julian Lam
2023-12-19 14:33:14 -05:00
parent 0d6f0530f5
commit 510763af30

View File

@@ -37,7 +37,8 @@ async function call(url, method, { body, timeout, jar, ...config } = {}) {
const { headers } = response; const { headers } = response;
const contentType = headers.get('content-type'); const contentType = headers.get('content-type');
const isJSON = contentType && contentType.indexOf('application/json') !== -1; const jsonTest = /application\/([a-z]+\+)?json/;
const isJSON = contentType && jsonTest.test(contentType);
let respBody = await response.text(); let respBody = await response.text();
if (isJSON && respBody) { if (isJSON && respBody) {
try { try {