]> source.dussan.org Git - nextcloud-server.git/commitdiff
make values with white spaces possible 3635/head
authorArtur Neumann <info@individual-it.net>
Tue, 28 Feb 2017 02:40:34 +0000 (08:25 +0545)
committerArtur Neumann <info@individual-it.net>
Tue, 28 Feb 2017 02:40:34 +0000 (08:25 +0545)
a user might enter values with white spaces, and that should be possible
and valid

Signed-off-by: Artur Neumann <info@individual-it.net>
core/js/js.js
core/js/tests/specs/coreSpec.js

index ba831e4251d3800b2ae2ccd1289bcb15d82a3132..44204f438c56c8b952cc7a3570867cd01f6b4b98 100644 (file)
@@ -1682,7 +1682,7 @@ OC.Util = {
                        return null;
                }
 
-               var s = string.toLowerCase();
+               var s = string.toLowerCase().trim();
                var bytes = null;
 
                var bytesArray = {
index faafb4797be215dc6c52a67bc0453464920dea6b..c9e8a60f2f16d899bf021196896e4a1fcd20b767 100644 (file)
@@ -619,6 +619,13 @@ describe('Core base tests', function() {
                                        ['B', null],
                                        ['40/0', null],
                                        ['40,30 kb', null],
+                                       [' 122.1 MB ', 128031130],
+                                       ['122.1 MB ', 128031130],
+                                       [' 122.1 MB ', 128031130],
+                                       ['      122.1 MB ', 128031130],
+                                       ['122.1    MB ', 128031130],
+                                       [' 125', 125],
+                                       [' 125 ', 125],
                                ];
                                for (var i = 0; i < data.length; i++) {
                                        expect(OC.Util.computerFileSize(data[i][0])).toEqual(data[i][1]);