mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: update isJSON test in request lib
This commit is contained in:
@@ -37,7 +37,8 @@ async function call(url, method, { body, timeout, jar, ...config } = {}) {
|
||||
|
||||
const { headers } = response;
|
||||
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();
|
||||
if (isJSON && respBody) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user