Skip to content

Commit

Permalink
Merge pull request #692 from skipperbent/v5-development
Browse files Browse the repository at this point in the history
Version 5.4.1.1
  • Loading branch information
skipperbent authored Nov 27, 2023
2 parents ef4756c + d17ee96 commit 3c03f08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/Pecee/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,6 @@ public function setUrl(Url $url): void
{
$this->url = $url;

if ($this->url->getHost() === null && $this->getHost() !== null) {
$this->url->setHost((string)$this->getHost());
}

if ($this->isSecure() === true) {
$this->url->setScheme('https');
}
Expand Down
11 changes: 8 additions & 3 deletions src/Pecee/Http/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ public function setScheme(string $scheme): self
/**
* Get url host
*
* @param bool $includeTrails Prepend // in front of hostname
* @return string|null
*/
public function getHost(): ?string
public function getHost(bool $includeTrails = false): ?string
{
if ((string)$this->host !== '' && $includeTrails === true) {
return '//' . $this->host;
}

return $this->host;
}

Expand Down Expand Up @@ -530,12 +535,12 @@ public function getAbsoluteUrl(bool $includeParams = true): string
*/
public function jsonSerialize(): string
{
return $this->getRelativeUrl();
return $this->getHost(true) . $this->getRelativeUrl();
}

public function __toString(): string
{
return $this->getRelativeUrl();
return $this->getHost(true) . $this->getRelativeUrl();
}

}

0 comments on commit 3c03f08

Please sign in to comment.