Skip to content

Commit

Permalink
fix #17191: improved consistency and readability of UrlManager::creat…
Browse files Browse the repository at this point in the history
…eAbsoluteUrl(, ) method
  • Loading branch information
ggh2e3 committed Dec 25, 2023
1 parent cdaf6f5 commit ff01ff8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Yii Framework 2 Change Log
2.0.50 under development
------------------------

- Bug #17191: Fixed `UrlManager::createUrl($params)` method now relies on `BaseUrl::isRelative($url)` method (ggh2e3)
- Bug #17191: Fix `UrlManager::createUrl($params)`, `UrlManager::createAbsoluteUrl($params, $scheme)` methods to rely on `BaseUrl::isRelative($url)` method (ggh2e3)
- Bug #17191: Fixed `BaseUrl::isRelative($url)` method in `yii\helpers\BaseUrl` (ggh2e3)
- Bug #18469: Fixed `Link::serialize(array $links)` method in `yii\web\Link` (ggh2e3)
- Bug #20040: Fix type `boolean` in `MSSQL` (terabytesoftw)
Expand Down
13 changes: 6 additions & 7 deletions framework/web/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,12 @@ public function createAbsoluteUrl($params, $scheme = null)
{
$params = (array) $params;
$url = $this->createUrl($params);
if (strpos($url, '://') === false) {
$hostInfo = $this->getHostInfo();
if (strncmp($url, '//', 2) === 0) {
$url = substr($hostInfo, 0, strpos($hostInfo, '://')) . ':' . $url;
} else {
$url = $hostInfo . $url;
}
$hostInfo = $this->getHostInfo();
if (Url::isRelative($url)) {
$url = $hostInfo . $url;
}

Check warning on line 559 in framework/web/UrlManager.php

View check run for this annotation

Codecov / codecov/patch

framework/web/UrlManager.php#L559

Added line #L559 was not covered by tests
if (strncmp($url, '//', 2) === 0) {
$url = substr($hostInfo, 0, strpos($hostInfo, '://')) . ':' . $url;
}

return Url::ensureScheme($url, $scheme);
Expand Down

0 comments on commit ff01ff8

Please sign in to comment.