From 82c644814952c6f4d0c47c1c5d114983ad56c3ba Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sat, 24 Sep 2022 00:30:18 +0200 Subject: [PATCH] Use no-break space in formatBytes Prevent tables cells containing byte sizes from having a line break inserted between the number and the byte unit when they get squished by using a no-break space instead of a regular space. --- packages/lib/helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/lib/helpers.js b/packages/lib/helpers.js index d2157d37..3738666e 100644 --- a/packages/lib/helpers.js +++ b/packages/lib/helpers.js @@ -105,10 +105,10 @@ function escapeRegExp(text) { */ function formatBytes(bytes) { if (bytes === 0) { - return "0 Bytes"; + return "0\u{A0}Bytes"; // No-break space } - let units = [" Bytes", " kB", " MB", " GB", " TB"]; + let units = ["\u{A0}Bytes", "\u{A0}kB", "\u{A0}MB", "\u{A0}GB", "\u{A0}TB"]; let factor = 1000; let power = Math.min(Math.floor(Math.log(bytes) / Math.log(factor)), units.length); return (power > 0 ? (bytes / factor ** power).toFixed(2) : bytes) + units[power];