diff --git a/modules/client/main/App.js b/modules/client/main/App.js index b16c729..41d06a8 100644 --- a/modules/client/main/App.js +++ b/modules/client/main/App.js @@ -83,7 +83,7 @@ function Stats({ data }) { of {formatBytes(totals.bandwidth.all)} of data to{' '} {formatNumber(totals.uniques.all)} unique visitors,{' '} - {formatPercent(totals.requests.cached / totals.requests.all, 0)}% + {formatPercent(totals.requests.cached / totals.requests.all, 2)}% {' '} of which were served from the cache.

diff --git a/modules/client/utils/formatPercent.js b/modules/client/utils/formatPercent.js index a88ecf5..e281005 100644 --- a/modules/client/utils/formatPercent.js +++ b/modules/client/utils/formatPercent.js @@ -1,3 +1,3 @@ -export default function formatPercent(n, fixed = 1) { - return String((n.toPrecision(2) * 100).toFixed(fixed)); +export default function formatPercent(n, decimals = 1) { + return (n * 100).toPrecision(decimals + 2); }