|
17 | 17 | use League\Uri\Exceptions\MissingFeature;
|
18 | 18 | use League\Uri\Exceptions\SyntaxError;
|
19 | 19 | use League\Uri\Idna\Converter as IdnaConverter;
|
20 |
| -use League\Uri\IPv4\Converter as Ipv4Converter; |
21 | 20 | use League\Uri\IPv6\Converter as IPv6Converter;
|
22 | 21 | use Stringable;
|
23 | 22 |
|
|
40 | 39 | use function substr;
|
41 | 40 | use function uksort;
|
42 | 41 |
|
| 42 | +use const FILTER_FLAG_IPV4; |
43 | 43 | use const FILTER_FLAG_IPV6;
|
44 | 44 | use const FILTER_VALIDATE_IP;
|
45 | 45 | use const PREG_SPLIT_NO_EMPTY;
|
@@ -289,8 +289,8 @@ public static function normalize(Stringable|string $uri): string
|
289 | 289 | }
|
290 | 290 |
|
291 | 291 | if (null !== $components['host'] &&
|
292 |
| - !IPv6Converter::isIpv6($components['host']) && |
293 |
| - !Ipv4Converter::fromEnvironment()->isIpv4($components['host']) |
| 292 | + false === filter_var($components['host'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && |
| 293 | + !IPv6Converter::isIpv6($components['host']) |
294 | 294 | ) {
|
295 | 295 | $components['host'] = IdnaConverter::toUnicode($components['host'])->domain();
|
296 | 296 | }
|
@@ -323,8 +323,8 @@ public static function normalizeAuthority(Stringable|string $authority): string
|
323 | 323 | {
|
324 | 324 | $components = UriString::parseAuthority($authority);
|
325 | 325 | if (null !== $components['host'] &&
|
326 |
| - !IPv6Converter::isIpv6($components['host']) && |
327 |
| - !Ipv4Converter::fromEnvironment()->isIpv4($components['host']) |
| 326 | + false === filter_var($components['host'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && |
| 327 | + !IPv6Converter::isIpv6($components['host']) |
328 | 328 | ) {
|
329 | 329 | $components['host'] = IdnaConverter::toUnicode((string) $components['host'])->domain();
|
330 | 330 | }
|
|
0 commit comments