Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit d5ea086

Browse files
committed
Fix URL copy method
1 parent ccf6b0d commit d5ea086

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WhatWg/Url.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use SensitiveParameter;
2525
use Uri\UriComparisonMode;
2626

27+
use function in_array;
2728
use function substr;
2829

2930
use const PHP_VERSION_ID;
@@ -82,6 +83,9 @@ private function copy(): self
8283
{
8384
$newInstance = (new ReflectionClass(self::class))->newInstanceWithoutConstructor();
8485
$newInstance->url = clone $this->url;
86+
$newInstance->unicodeHost = null;
87+
$newInstance->unicodeHostInitialized = false;
88+
$newInstance->urlUnicodeString = null;
8589

8690
return $newInstance;
8791
}
@@ -184,7 +188,7 @@ private function setUnicodeHost(): ?string
184188
*/
185189
public function withHost(string $host): self
186190
{
187-
if ($host === $this->getAsciiHost() || $host === $this->getUnicodeHost()) {
191+
if (in_array($host, [$this->url->hostname, $this->getAsciiHost(), $this->getUnicodeHost()], true)) {
188192
return $this;
189193
}
190194

0 commit comments

Comments
 (0)