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

David Prévot taffit at moszumanska.debian.org
Wed Mar 11 15:49:45 UTC 2015


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

taffit pushed a commit to annotated tag v8.0.1
in repository owncloud.

commit cc243e1296a343c5440e19fcf2ded8d7abacbec0
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 234cc32..78342ce 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 d283839..159c374 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'],

-- 
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