Skip to content

Commit 3c03f08

Browse files
authored
Merge pull request #692 from skipperbent/v5-development
Version 5.4.1.1
2 parents ef4756c + d17ee96 commit 3c03f08

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Pecee/Http/Request.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ public function setUrl(Url $url): void
395395
{
396396
$this->url = $url;
397397

398-
if ($this->url->getHost() === null && $this->getHost() !== null) {
399-
$this->url->setHost((string)$this->getHost());
400-
}
401-
402398
if ($this->isSecure() === true) {
403399
$this->url->setScheme('https');
404400
}

src/Pecee/Http/Url.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,15 @@ public function setScheme(string $scheme): self
144144
/**
145145
* Get url host
146146
*
147+
* @param bool $includeTrails Prepend // in front of hostname
147148
* @return string|null
148149
*/
149-
public function getHost(): ?string
150+
public function getHost(bool $includeTrails = false): ?string
150151
{
152+
if ((string)$this->host !== '' && $includeTrails === true) {
153+
return '//' . $this->host;
154+
}
155+
151156
return $this->host;
152157
}
153158

@@ -530,12 +535,12 @@ public function getAbsoluteUrl(bool $includeParams = true): string
530535
*/
531536
public function jsonSerialize(): string
532537
{
533-
return $this->getRelativeUrl();
538+
return $this->getHost(true) . $this->getRelativeUrl();
534539
}
535540

536541
public function __toString(): string
537542
{
538-
return $this->getRelativeUrl();
543+
return $this->getHost(true) . $this->getRelativeUrl();
539544
}
540545

541546
}

0 commit comments

Comments
 (0)