mirror of https://github.com/Lissy93/dashy.git
🔒 Feed input through parseFlot() as means of sanitisation
This commit is contained in:
parent
ee46f2a33e
commit
7d8d3078b2
|
@ -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]}`;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue