mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
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.
This commit is contained in:
1 parent
9fb3d6d8db
commit
82c6448149
1 file changed
+2
-2
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user