Skip to content

Commit cccfcb0

Browse files
committed
Improve Uri related interface and implementation
1 parent b2322d2 commit cccfcb0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Uri.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,11 +1748,17 @@ public function equals(UriInterface|Stringable|string $uri, bool $excludeFragmen
17481748
$uri = self::tryNew($uri);
17491749
}
17501750

1751-
return match(true) {
1752-
null === $uri => false,
1753-
$excludeFragment => $uri->withFragment(null)->toNormalizedString() === $this->withFragment(null)->toNormalizedString(),
1754-
default => $uri->toNormalizedString() === $this->toNormalizedString(),
1755-
};
1751+
if (null === $uri) {
1752+
return false;
1753+
}
1754+
1755+
$baseUri = $this;
1756+
if ($excludeFragment) {
1757+
$uri = $uri->withFragment(null);
1758+
$baseUri = $baseUri->withFragment(null);
1759+
}
1760+
1761+
return $uri->normalize()->toString() === $baseUri->normalize()->toString();
17561762
}
17571763

17581764
/**

0 commit comments

Comments
 (0)