From 73c62010b71a358221f1808e334759af34732b27 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 3 Oct 2023 10:39:38 +0200 Subject: [PATCH] Fix rounding response size I noticed that sometimes the response size is weirdly displayed. - size `112932` is displayed as `110.28.999999999999996KB` - size `112990` is displayed as `110.34KB` The problem is in the decimal calculation. Rounding the value ensure we don't have two `.` in the displayed size. Also, update the `contributing` to increase the minimum Node version required. --- contributing.md | 2 +- .../bruno-app/src/components/ResponsePane/ResponseSize/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contributing.md b/contributing.md index 6b70dc02..a538f1bd 100644 --- a/contributing.md +++ b/contributing.md @@ -19,7 +19,7 @@ Libraries we use ### Dependencies -You would need [Node v14.x or the latest LTS version](https://nodejs.org/en/) and npm 8.x. We use npm workspaces in the project +You would need [Node v18.x or the latest LTS version](https://nodejs.org/en/) and npm 8.x. We use npm workspaces in the project ### Lets start coding diff --git a/packages/bruno-app/src/components/ResponsePane/ResponseSize/index.js b/packages/bruno-app/src/components/ResponsePane/ResponseSize/index.js index c3c2f1fe..2500474c 100644 --- a/packages/bruno-app/src/components/ResponsePane/ResponseSize/index.js +++ b/packages/bruno-app/src/components/ResponsePane/ResponseSize/index.js @@ -7,7 +7,7 @@ const ResponseSize = ({ size }) => { if (size > 1024) { // size is greater than 1kb let kb = Math.floor(size / 1024); - let decimal = ((size % 1024) / 1024).toFixed(2) * 100; + let decimal = Math.round(((size % 1024) / 1024).toFixed(2) * 100); sizeToDisplay = kb + '.' + decimal + 'KB'; } else { sizeToDisplay = size + 'B';