Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow for lowercase as well, also strip the unit part off before pow()

  • Loading branch information...
commit ff676b5ea4a2c19d2bf3205d72bde81d61a5db97 1 parent 90c32ad
@ceeram ceeram authored
View
1  lib/Cake/Test/Case/Utility/CakeNumberTest.php
@@ -555,6 +555,7 @@ public function filesizes() {
array(array('size' => '1KB', 'default' => false), 1024),
array(array('size' => '1.5KB', 'default' => false), 1536),
array(array('size' => '1MB', 'default' => false), 1048576),
+ array(array('size' => '1mb', 'default' => false), 1048576),
array(array('size' => '1.5MB', 'default' => false), 1572864),
array(array('size' => '1GB', 'default' => false), 1073741824),
array(array('size' => '1.5GB', 'default' => false), 1610612736),
View
3  lib/Cake/Utility/CakeNumber.php
@@ -112,13 +112,16 @@ public static function fromReadableSize($size, $default = false) {
if (ctype_digit($size)) {
return $size * 1;
}
+ $size = strtoupper($size);
$i = array_search(substr($size, -2), array('KB', 'MB', 'GB', 'TB', 'PB'));
if ($i !== false) {
+ $size = substr($size, 0, strlen($size) -2);
return $size * pow(1024, $i + 1);
}
if (substr($size, -1) == 'B' && ctype_digit(substr($size, 0, strlen($size) - 1))) {
+ $size = substr($size, 0, strlen($size) - 1);
return $size * 1;
}
Please sign in to comment.
Something went wrong with that request. Please try again.