mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
adding quotes in text response
This commit is contained in:
parent
582e8e5eac
commit
9a2d8bfff3
@ -27,14 +27,13 @@ const formatResponse = (data, mode, filter) => {
|
||||
let isValidJSON = false;
|
||||
|
||||
try {
|
||||
isValidJSON =
|
||||
typeof JSON.parse(JSON.stringify(data)) === 'object' || typeof JSON.parse(JSON.stringify(data)) === 'string';
|
||||
isValidJSON = typeof JSON.parse(JSON.stringify(data)) === 'object'
|
||||
} catch (error) {
|
||||
console.log('Error parsing JSON: ', error.message);
|
||||
}
|
||||
|
||||
if (!isValidJSON && typeof data === 'string') {
|
||||
return data;
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
|
@ -366,7 +366,10 @@ const parseDataFromResponse = (response, disableParsingResponseJson = false) =>
|
||||
// Filter out ZWNBSP character
|
||||
// https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d
|
||||
data = data.replace(/^\uFEFF/, '');
|
||||
if (!disableParsingResponseJson) {
|
||||
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)
|
||||
) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
} catch { }
|
||||
|
Loading…
Reference in New Issue
Block a user