diff --git a/src/components/Response/Redirect.js b/src/components/Response/Redirect.js index b228079..0176c6f 100644 --- a/src/components/Response/Redirect.js +++ b/src/components/Response/Redirect.js @@ -23,6 +23,7 @@ function Titlebar({ url, time, size, statusCode, onClick }) { Titlebar.propTypes = { url: redirectShape.url, time: redirectShape.time, + size: PropTypes.number.isRequired, statusCode: PropTypes.number.isRequired, onClick: PropTypes.func.isRequired, }; @@ -39,8 +40,8 @@ function Redirect(props) { const { method, url, time, statusCode } = response; - const contentLength = headers.find((header) => header.name.toLowerCase() === 'content-length') - const contentSize = contentLength ? Number(contentLength.value) : 0 + const contentLength = headers.find(header => (header.name.toLowerCase() === 'content-length')); + const contentSize = contentLength ? Number(contentLength.value) : 0; return ( } + header={( + + )} > {type.html && } diff --git a/src/components/Response/SizeBytes.js b/src/components/Response/SizeBytes.js index b04b09e..cbe9ae6 100644 --- a/src/components/Response/SizeBytes.js +++ b/src/components/Response/SizeBytes.js @@ -11,7 +11,7 @@ function SizeBytes({ size }) { } SizeBytes.propTypes = { - size: PropTypes.number.isRequired + size: PropTypes.number.isRequired, }; export default SizeBytes; diff --git a/src/utils/byteFormatter.js b/src/utils/byteFormatter.js index 75649cf..1878f6c 100644 --- a/src/utils/byteFormatter.js +++ b/src/utils/byteFormatter.js @@ -1,14 +1,14 @@ -const KB = 1024 -const MB = 1024 * KB -const GB = 1024 * MB +const KB = 1024; +const MB = 1024 * KB; +const GB = 1024 * MB; /* * Formats the provided number in bytes as a string of bytes, * KB, MB, or GB, with one decimal point and the unit suffix. */ export default function byteFormatter(bytes) { - if (bytes < 100) return `${bytes} bytes` - if (bytes > GB) return (bytes / GB).toFixed(1) + ' GB' - if (bytes > MB) return (bytes / MB).toFixed(1) + ' MB' - return (bytes / KB).toFixed(1) + ' KB' -} + if (bytes < 100) return `${bytes} bytes`; + if (bytes > GB) return `${(bytes / GB).toFixed(1)} GB`; + if (bytes > MB) return `${(bytes / MB).toFixed(1)} MB`; + return `${(bytes / KB).toFixed(1)} KB`; +};