diff options
-rw-r--r-- | core/js/js.js | 4 | ||||
-rw-r--r-- | core/js/tests/specs/coreSpec.js | 6 | ||||
-rw-r--r-- | lib/private/naturalsort.php | 3 | ||||
-rw-r--r-- | tests/lib/naturalsort.php | 4 |
4 files changed, 14 insertions, 3 deletions
diff --git a/core/js/js.js b/core/js/js.js index b6bfa01d0d5..60791dcc8d8 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -1373,7 +1373,8 @@ OC.Util = { while (x < t.length) { c = t.charAt(x); - var m = (c === '.' || (c >= '0' && c <= '9')); + // only include the dot in strings + var m = ((!n && c === '.') || (c >= '0' && c <= '9')); if (m !== n) { // next chunk y++; @@ -1393,6 +1394,7 @@ OC.Util = { * or 0 if the strings are identical */ naturalSortCompare: function(a, b) { + var x; var aa = OC.Util._chunkify(a); var bb = OC.Util._chunkify(b); diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 265b9deac39..6d40a066de8 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -531,10 +531,14 @@ describe('Core base tests', function() { 'za', 'ghi 1.txt', 'ghi 12.txt', - 'zz' + 'zz', + '15.txt', + '15b.txt' ]; a.sort(OC.Util.naturalSortCompare); expect(a).toEqual([ + '15.txt', + '15b.txt', '123.txt', '124.txt', 'abc', diff --git a/lib/private/naturalsort.php b/lib/private/naturalsort.php index b6fa0ed8968..e10ce8e45e7 100644 --- a/lib/private/naturalsort.php +++ b/lib/private/naturalsort.php @@ -39,7 +39,8 @@ class NaturalSort { while ($x < $length) { $c = $t[$x]; - $m = ($c === '.' || ($c >= '0' && $c <= '9')); + // only include the dot in strings + $m = ((!$n && $c === '.') || ($c >= '0' && $c <= '9')); if ($m !== $n) { // next chunk $y++; diff --git a/tests/lib/naturalsort.php b/tests/lib/naturalsort.php index a880acaeec4..09a0e6a5f9d 100644 --- a/tests/lib/naturalsort.php +++ b/tests/lib/naturalsort.php @@ -74,9 +74,13 @@ class Test_NaturalSort extends PHPUnit_Framework_TestCase { 'ghi 1.txt', 'ghi 12.txt', 'zz', + '15.txt', + '15b.txt', ), // sorted array( + '15.txt', + '15b.txt', '123.txt', '124.txt', 'abc', |