Skip to content

Commit

Permalink
[HttpClient] Fix empty hosts in option "resolve"
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 19, 2024
1 parent 582cf3a commit 43f2764
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions HttpClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
$options['resolve'] = [];
foreach ($resolve as $k => $v) {
if ('' === $v = (string) $v) {
throw new InvalidArgumentException(sprintf('Option "resolve" for host "%s" cannot be empty.', $k));
}
if ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
$v = null;
} elseif ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
$v = substr($v, 1, -1);
}

Expand Down Expand Up @@ -228,9 +227,8 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
if ($resolve = $defaultOptions['resolve'] ?? false) {
foreach ($resolve as $k => $v) {
if ('' === $v = (string) $v) {
throw new InvalidArgumentException(sprintf('Option "resolve" for host "%s" cannot be empty.', $k));
}
if ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
$v = null;
} elseif ('[' === $v[0] && ']' === substr($v, -1) && str_contains($v, ':')) {
$v = substr($v, 1, -1);
}

Expand Down

0 comments on commit 43f2764

Please sign in to comment.