From b6b4b7362fb6decf407fdc81a11d527ecfe5d4c7 Mon Sep 17 00:00:00 2001 From: Pooja Belaramani Date: Fri, 27 Dec 2024 15:51:06 +0530 Subject: [PATCH] fix: condition --- packages/bruno-electron/src/ipc/network/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 479cb0d04..6685e95ab 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -365,14 +365,17 @@ const parseDataFromResponse = (response, disableParsingResponseJson = false) => try { // Filter out ZWNBSP character // https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d + + // a quoated string is also a vaild json but we want to show it as a quoated string only (parsing removes the quoates) data = data.replace(/^\uFEFF/, ''); - if ( - !disableParsingResponseJson - && !(data.startsWith("\"") && data.endsWith("\"")) // a quoated string is also a vaild json but we want to show it as a quoated string only (parsing removes the quoates) - ) { + if ( !disableParsingResponseJson && ! (typeof data === 'string' && data.startsWith("\"") && data.endsWith("\""))) { + data = JSON.parse(data); + } { data = JSON.parse(data); } - } catch { } + } catch { + console.log('Failed to parse response data as JSON'); + } return { data, dataBuffer }; };