Fixes for 2 code quality findings (#3302)

* Apply suggested fix to src/themes/admin_default/assets/js/utils.js from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

* Apply suggested fix to src/themes/admin_default/assets/js/utils.js from Copilot Autofix

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This commit is contained in:
Adam DaleyandCopilot Autofix powered by AI authored and GitHub committed 2026-03-10 07:12:39 +00:00
1 parent 21de5d8d21
commit e21ebfcc4a
1 file changed
+3 -2
+3 -2
View File
@@ -145,15 +145,16 @@ export function scrollToElement(target, options = {}) {
* @returns {string} Formatted string
*/
export function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
if (!Number.isFinite(bytes) || bytes <= 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
const index = Math.min(Math.max(i, 0), sizes.length - 1);
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
return parseFloat((bytes / Math.pow(k, index)).toFixed(dm)) + ' ' + sizes[index];
}
/**