Skip to content

Commit

Permalink
Add support for IPv4-IPv6 conversion (#142)
Browse files Browse the repository at this point in the history
Add support for IPv4-IPv6 conversion
  • Loading branch information
nyamsprod authored Jul 26, 2024
1 parent 1b48cb1 commit 861c2a7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use League\Uri\Contracts\UriAccess;
use League\Uri\Contracts\UriInterface;
use League\Uri\Exceptions\MissingFeature;
use League\Uri\Idna\Converter;
use League\Uri\Idna\Converter as IdnaConverter;
use League\Uri\IPv4\Converter as IPv4Converter;
use League\Uri\IPv6\Converter as IPv6Converter;
use Psr\Http\Message\UriFactoryInterface;
Expand Down Expand Up @@ -267,7 +267,15 @@ public function isSameDocument(Stringable|string $uri): bool
*/
public function hasIdn(): bool
{
return Converter::isIdn($this->uri->getHost());
return IdnaConverter::isIdn($this->uri->getHost());
}

/**
* Tells whether the URI contains an IPv4 regardless if it is mapped or native
*/
public function hasIPv4(): bool
{
return IPv4Converter::fromEnvironment()->isIpv4($this->uri->getHost());
}

/**
Expand Down

0 comments on commit 861c2a7

Please sign in to comment.