mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 19:49:20 +03:00
Prevent Infinity #1540
This commit is contained in:
parent
969dca5f7e
commit
bcc2c7b9ca
3 changed files with 5 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint key-spacing: 0 */
|
||||
/* eslint quote-props: 0 */
|
||||
|
||||
import { arrayLength } from 'Common/Utils';
|
||||
import { arrayLength, pInt } from 'Common/Utils';
|
||||
|
||||
export const RFC822 = 'message/rfc822';
|
||||
|
||||
|
|
@ -274,8 +274,7 @@ export const FileInfo = {
|
|||
},
|
||||
|
||||
friendlySize: bytes => {
|
||||
bytes = parseInt(bytes, 10);
|
||||
bytes = isFinite(bytes) ? bytes : 0;
|
||||
bytes = pInt(bytes);
|
||||
let i = bytes ? Math.floor(Math.log(bytes) / Math.log(1024)) : 0;
|
||||
return (bytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + ' ' + sizes[i];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export const
|
|||
|
||||
pInt = (value, defaultValue = 0) => {
|
||||
value = parseInt(value, 10);
|
||||
return isNaN(value) || !isFinite(value) ? defaultValue : value;
|
||||
return isFinite(value) ? value : defaultValue;
|
||||
},
|
||||
|
||||
defaultOptionsAfterRender = (domItem, item) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue