Skip to content

Commit b46e267

Browse files
authored
Fix #17181: Improved BaseUrl::isRelative($url) performance
1 parent dea891e commit b46e267

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Yii Framework 2 Change Log
44
2.0.50 under development
55
------------------------
66

7+
- Bug #17181: Improved `BaseUrl::isRelative($url)` performance (sammousa, bizley, rob006)
78
- Bug #17191: Fixed `BaseUrl::isRelative($url)` method in `yii\helpers\BaseUrl` (ggh2e3)
89
- Bug #18469: Fixed `Link::serialize(array $links)` method in `yii\web\Link` (ggh2e3)
910
- Bug #20040: Fix type `boolean` in `MSSQL` (terabytesoftw)

framework/helpers/BaseUrl.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ public static function home($scheme = false)
378378
*/
379379
public static function isRelative($url)
380380
{
381-
$urlComponents = parse_url($url, PHP_URL_SCHEME);
382-
return strncmp($url, '//', 2) && empty($urlComponents);
381+
return preg_match('~^[[:alpha:]][[:alnum:]+-.]*://|^//~', $url) === 0;
383382
}
384383

385384
/**

0 commit comments

Comments
 (0)