Skip to content

Commit

Permalink
fix: BigInters are now correctly shown in the response (#2736)
Browse files Browse the repository at this point in the history
Fixes: #1753
  • Loading branch information
Its-treason authored Aug 6, 2024
1 parent aa4bcdc commit 3e2a3b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/bruno-app/src/utils/common/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { customAlphabet } from 'nanoid';
import xmlFormat from 'xml-formatter';
import { stringify } from 'lossless-json';

// a customized version of nanoid without using _ and -
export const uuid = () => {
Expand Down Expand Up @@ -43,9 +44,9 @@ export const safeStringifyJSON = (obj, indent = false) => {
}
try {
if (indent) {
return JSON.stringify(obj, null, 2);
return stringify(obj, null, 2);
}
return JSON.stringify(obj);
return stringify(obj);
} catch (e) {
return obj;
}
Expand Down
1 change: 1 addition & 0 deletions packages/bruno-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"js-yaml": "^4.1.0",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"lossless-json": "^4.0.1",
"mime-types": "^2.1.35",
"mustache": "^4.2.0",
"nanoid": "3.3.4",
Expand Down
7 changes: 6 additions & 1 deletion packages/bruno-electron/src/ipc/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const {
} = require('./oauth2-helper');
const Oauth2Store = require('../../store/oauth2');
const iconv = require('iconv-lite');
const { parse, LosslessNumber } = require('lossless-json');

// override the default escape function to prevent escaping
Mustache.escape = function (value) {
Expand Down Expand Up @@ -285,7 +286,11 @@ const parseDataFromResponse = (response) => {
// Filter out ZWNBSP character
// https://gist.github.com/antic183/619f42b559b78028d1fe9e7ae8a1352d
data = data.replace(/^\uFEFF/, '');
data = JSON.parse(data);
data = parse(data, null, (value) => {
// By default, this will return the LosslessNumber object, but because it's passed into ipc we
// need to convert it into a number because LosslessNumber is converted into an object
return new LosslessNumber(value).valueOf();
});
} catch {}

return { data, dataBuffer };
Expand Down

0 comments on commit 3e2a3b6

Please sign in to comment.