Prefer strpos to substr

This commit is contained in:
Alexander Makarov
2016-12-15 23:47:52 +03:00
committed by Carsten Brandt
parent c641513583
commit f9e83008f4
2 changed files with 4 additions and 4 deletions

View File

@ -396,7 +396,7 @@ class UrlManager extends Component
} else {
return $url . $baseUrl . $anchor;
}
} elseif (substr($url, 0, 2) === '//') {
} elseif (strpos($url, '//') === 0) {
if ($baseUrl !== '' && ($pos = strpos($url, '/', 2)) !== false) {
return substr($url, 0, $pos) . $baseUrl . substr($url, $pos) . $anchor;
} else {
@ -482,7 +482,7 @@ class UrlManager extends Component
$url = $this->createUrl($params);
if (strpos($url, '://') === false) {
$hostInfo = $this->getHostInfo();
if (substr($url, 0, 2) === '//') {
if (strpos($url, '//') === 0) {
$url = substr($hostInfo, 0, strpos($hostInfo, '://')) . ':' . $url;
} else {
$url = $hostInfo . $url;