Do not print bytes with decimal place

This commit is contained in:
René Pfeuffer
2018-10-19 13:01:06 +02:00
parent 47ccc178f6
commit 5a454139da

View File

@@ -14,7 +14,7 @@ class FileSize extends React.Component<Props> {
const units = ["B", "K", "M", "G", "T", "P", "E", "Z", "Y"];
const i = Math.floor(Math.log(bytes) / Math.log(1024));
const size = (bytes / 1024 ** i).toFixed(2);
const size = i === 0 ? bytes : (bytes / 1024 ** i).toFixed(2);
return `${size} ${units[i]}`;
}