Skip to content

Commit f00f798

Browse files
committed
adjusted where ext-mbstring is suggested
will use mbstring if extn installed
1 parent d25b2bf commit f00f798

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
],
1616
"require": {
1717
"php": ">=5.3",
18-
"ext-curl": "*",
19-
"ext-mbstring": "*"
18+
"ext-curl": "*"
2019
},
2120
"require-dev": {
2221
"ext-gd": "*",
2322
"phpunit/phpunit": "*",
2423
"squizlabs/php_codesniffer": "*"
2524
},
25+
"suggest": {
26+
"ext-mbstring": "*"
27+
},
2628
"autoload": {
2729
"psr-4": {
2830
"Curl\\": "src/Curl/"

src/Curl/StringUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class StringUtil
1515
*/
1616
public static function startsWith($haystack, $needle)
1717
{
18-
return \mb_substr($haystack, 0, \mb_strlen($needle)) === $needle;
18+
return (function_exists("\mb_substr") ? (\mb_substr($haystack, 0, \mb_strlen($needle)) === $needle) : (\substr($haystack, 0, \strlen($needle)) === $needle));
1919
}
2020
}

src/Curl/Url.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public static function removeDotSegments($input)
5656
// buffer; otherwise,
5757
} elseif (StringUtil::startsWith($input, '/../')) {
5858
$input = substr($input, 3);
59-
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
59+
$output = substr_replace($output, '', (function_exists('\mb_strrpos') ? \mb_strrpos($output, '/') : \strrpos($output, '/')));
6060
} elseif ($input === '/..') {
6161
$input = '/';
62-
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
62+
$output = substr_replace($output, '', (function_exists('\mb_strrpos') ? \mb_strrpos($output, '/') : \strrpos($output, '/') ));
6363

6464
// D. if the input buffer consists only of "." or "..", then remove
6565
// that from the input buffer; otherwise,
@@ -70,7 +70,7 @@ public static function removeDotSegments($input)
7070
// the output buffer, including the initial "/" character (if
7171
// any) and any subsequent characters up to, but not including,
7272
// the next "/" character or the end of the input buffer.
73-
} elseif (!(($pos = \mb_strpos($input, '/', 1)) === false)) {
73+
} elseif (!(($pos = (function_exists('\mb_strpos') ? \mb_strpos($input, '/', 1) : \strpos($input, '/', 1) )) === false)) {
7474
$output .= substr($input, 0, $pos);
7575
$input = substr_replace($input, '', 0, $pos);
7676
} else {
@@ -131,7 +131,7 @@ private function absolutizeUrl()
131131
if (StringUtil::startsWith($r['path'], '/')) {
132132
$target['path'] = self::removeDotSegments($r['path']);
133133
} else {
134-
$base = \mb_strrchr($b['path'], '/', true);
134+
$base = (function_exists('\mb_strrchr') ? \mb_strrchr($b['path'], '/', true) : \strrchr($b['path'], '/'));
135135
if ($base === false) {
136136
$base = '';
137137
}

0 commit comments

Comments
 (0)