adjusted where ext-mbstring is suggested

will use mbstring if extn installed
This commit is contained in:
Jared Spencer
2018-12-18 17:49:18 -07:00
parent d25b2bff6f
commit f00f7988d3
3 changed files with 9 additions and 7 deletions
+4 -2
View File
@@ -15,14 +15,16 @@
],
"require": {
"php": ">=5.3",
"ext-curl": "*",
"ext-mbstring": "*"
"ext-curl": "*"
},
"require-dev": {
"ext-gd": "*",
"phpunit/phpunit": "*",
"squizlabs/php_codesniffer": "*"
},
"suggest": {
"ext-mbstring": "*"
},
"autoload": {
"psr-4": {
"Curl\\": "src/Curl/"
+1 -1
View File
@@ -15,6 +15,6 @@ class StringUtil
*/
public static function startsWith($haystack, $needle)
{
return \mb_substr($haystack, 0, \mb_strlen($needle)) === $needle;
return (function_exists("\mb_substr") ? (\mb_substr($haystack, 0, \mb_strlen($needle)) === $needle) : (\substr($haystack, 0, \strlen($needle)) === $needle));
}
}
+4 -4
View File
@@ -56,10 +56,10 @@ class Url
// buffer; otherwise,
} elseif (StringUtil::startsWith($input, '/../')) {
$input = substr($input, 3);
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
$output = substr_replace($output, '', (function_exists('\mb_strrpos') ? \mb_strrpos($output, '/') : \strrpos($output, '/')));
} elseif ($input === '/..') {
$input = '/';
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
$output = substr_replace($output, '', (function_exists('\mb_strrpos') ? \mb_strrpos($output, '/') : \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 = (function_exists('\mb_strpos') ? \mb_strpos($input, '/', 1) : \strpos($input, '/', 1) )) === false)) {
$output .= substr($input, 0, $pos);
$input = substr_replace($input, '', 0, $pos);
} else {
@@ -131,7 +131,7 @@ class Url
if (StringUtil::startsWith($r['path'], '/')) {
$target['path'] = self::removeDotSegments($r['path']);
} else {
$base = \mb_strrchr($b['path'], '/', true);
$base = (function_exists('\mb_strrchr') ? \mb_strrchr($b['path'], '/', true) : \strrchr($b['path'], '/'));
if ($base === false) {
$base = '';
}