Skip to content

Commit

Permalink
fix: show '0 B' instead of '-' for zero-length files (#2018)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Sep 12, 2022
1 parent b76c0db commit fda3bf5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/files/file/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const File = ({
styles.borderTop = '1px solid #eee'
}

size = size ? humanSize(size, { round: 0 }) : '-'
size = humanSize(size, { round: 0 })
const hash = cid.toString() || t('hashUnavailable')

const select = (select) => onSelect(name, select)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export async function getCarLink (files, gatewayUrl, ipfs) {
* @returns {string} human-readable size
*/
export function humanSize (size, opts) {
if (typeof size === 'undefined') return 'N/A'
if (typeof size === 'undefined' || size === null) return 'N/A'
return filesize(size || 0, {
// base-2 byte units (GiB, MiB, KiB) to remove any ambiguity
spacer: String.fromCharCode(160), // non-breakable space (&nbsp)
Expand Down

0 comments on commit fda3bf5

Please sign in to comment.