summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-01-29 17:27:28 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-01-29 17:27:28 +0100
commitccc1f096273b81ba29ef2dfbfad6baaf7ecd0082 (patch)
tree678bbe29514f5e7cc81ca5f63d9233587c4a3461 /core
parent5c8e5e223d07780196680732544fa66a5fa2503c (diff)
downloadnextcloud-server-ccc1f096273b81ba29ef2dfbfad6baaf7ecd0082.tar.gz
nextcloud-server-ccc1f096273b81ba29ef2dfbfad6baaf7ecd0082.zip
generate valid human readable text for 0 - fixed #9342
Diffstat (limited to 'core')
-rw-r--r--core/js/js.js2
-rw-r--r--core/js/tests/specs/coreSpec.js2
2 files changed, 3 insertions, 1 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 234cc328dfb..78342ce97bd 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1213,7 +1213,7 @@ $.fn.filterAttr = function(attr_name, attr_value) {
function humanFileSize(size, skipSmallSizes) {
var humanList = ['B', 'kB', 'MB', 'GB', 'TB'];
// Calculate Log with base 1024: size = 1024 ** order
- var order = size?Math.floor(Math.log(size) / Math.log(1024)):0;
+ var order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0;
// Stay in range of the byte sizes that are defined
order = Math.min(humanList.length - 1, order);
var readableFormat = humanList[order];
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index d283839d7e7..159c3743662 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -465,6 +465,8 @@ describe('Core base tests', function() {
it('renders file sizes with the correct unit', function() {
var data = [
[0, '0 B'],
+ ["0", '0 B'],
+ ["A", 'NaN B'],
[125, '125 B'],
[128000, '125 kB'],
[128000000, '122.1 MB'],