Skip to content

Commit

Permalink
Improve IDNA feature for version 7
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jul 29, 2023
1 parent f20bf93 commit 8c8629c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use League\Uri\Exceptions\IdnSupportMissing;
use League\Uri\Exceptions\SyntaxError;
use League\Uri\Idna\Idna;
use League\Uri\Idna\IdnaOption;
use League\Uri\UriTemplate\TemplateCanNotBeExpanded;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
use SensitiveParameter;
Expand Down Expand Up @@ -338,10 +339,10 @@ private function formatHost(?string $host): ?string
private function formatRegisteredName(string $host): string
{
$formatter = static function (string $host) {
$info = Idna::toAscii($host, Idna::IDNA2008_ASCII);
$info = Idna::toAscii($host, IdnaOption::forIDNA2008Ascii());

return match (true) {
0 !== $info->errors() => throw IdnaConversionFailed::dueToIDNAError($host, $info),
$info->hasErrors() => throw IdnaConversionFailed::dueToIDNAError($host, $info),
default => $info->result(),
};
};
Expand Down

0 comments on commit 8c8629c

Please sign in to comment.