Merge pull request #518 from zachborboa/master

Require mbstring extension to use library
This commit is contained in:
Zach Borboa
2018-04-28 16:37:40 -07:00
committed by GitHub
4 changed files with 8 additions and 6 deletions
+2 -1
View File
@@ -14,7 +14,8 @@
],
"require": {
"php": ">=5.3",
"ext-curl": "*"
"ext-curl": "*",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "*",
+1 -1
View File
@@ -15,6 +15,6 @@ class StrUtil
*/
public static function startsWith($haystack, $needle)
{
return mb_substr($haystack, 0, mb_strlen($needle)) === $needle;
return \mb_substr($haystack, 0, \mb_strlen($needle)) === $needle;
}
}
+4 -4
View File
@@ -56,10 +56,10 @@ class Url
// buffer; otherwise,
} elseif (StrUtil::startsWith($input, '/../')) {
$input = substr($input, 3);
$output = substr_replace($output, '', mb_strrpos($output, '/'));
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
} elseif ($input === '/..') {
$input = '/';
$output = substr_replace($output, '', mb_strrpos($output, '/'));
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
// D. if the input buffer consists only of "." or "..", then remove
// that from the input buffer; otherwise,
@@ -70,7 +70,7 @@ class Url
// the output buffer, including the initial "/" character (if
// any) and any subsequent characters up to, but not including,
// the next "/" character or the end of the input buffer.
} elseif (!(($pos = mb_strpos($input, '/', 1)) === false)) {
} elseif (!(($pos = \mb_strpos($input, '/', 1)) === false)) {
$output .= substr($input, 0, $pos);
$input = substr_replace($input, '', 0, $pos);
} else {
@@ -131,7 +131,7 @@ class Url
if (StrUtil::startsWith($r['path'], '/')) {
$target['path'] = self::removeDotSegments($r['path']);
} else {
$base = mb_strrchr($b['path'], '/', true);
$base = \mb_strrchr($b['path'], '/', true);
if ($base === false) {
$base = '';
}
+1
View File
@@ -12,6 +12,7 @@ class CurlTest extends \PHPUnit\Framework\TestCase
{
$this->assertTrue(extension_loaded('curl'));
$this->assertTrue(extension_loaded('gd'));
$this->assertTrue(extension_loaded('mbstring'));
}
public function testArrayAssociative()