[Pkg-owncloud-commits] [owncloud] 10/16: generate valid human readable text for 0 - fixed #9342

David Prévot taffit at moszumanska.debian.org
Thu Oct 22 15:55:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 75d4dac8ed68ddc8e23105bc39568d8a1c42f289
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Thu Jan 29 17:27:28 2015 +0100

    generate valid human readable text for 0 - fixed #9342
---
 core/js/js.js                   | 2 +-
 core/js/tests/specs/coreSpec.js | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/js/js.js b/core/js/js.js
index 4154657..77e0854 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1225,7 +1225,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 e828e4e..f91943b 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -462,6 +462,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'],

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list