mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Prefer strpos to substr
This commit is contained in:

committed by
Carsten Brandt

parent
c641513583
commit
f9e83008f4
@ -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;
|
||||
|
Reference in New Issue
Block a user