🔒 Feed input through parseFlot() as means of sanitisation

This commit is contained in:
Marcell Fülöp 2022-06-20 17:38:23 +00:00
parent ee46f2a33e
commit 7d8d3078b2
1 changed files with 1 additions and 1 deletions

View File

@ -113,7 +113,7 @@ export const formatNumber = (number, decimals = 1) => {
const units = ['', 'K', 'M', 'B', 'T'];
const k = 1000;
const i = Math.floor(Math.log(number) / Math.log(k));
const f = number / (k ** i);
const f = parseFloat(number / (k ** i));
const d = f.toFixed(decimals) % 1.0 === 0 ? 0 : decimals; // number of decimals, omit .0
return `${f.toFixed(d)}${units[i]}`;
};