Absolute URL validation
UrlHelper::isValid($url, TRUE) now accepts absolute URLs containing internationalized domain names in either Unicode or Punycode. For example, https://café.example and https://xn--caf-dma.example both pass validation. This also applies to Form API elements of type url that use the standard URL validator.
Drupal recognizes equivalent hostnames when checking local redirects, generating file and asset URLs, handling oEmbed iframes, and selecting a language by domain.
Comparing hostnames in custom and contributed code
Drupal\Component\Utility\UrlHelper provides two new public methods:
UrlHelper::toAsciiHost(string $host): ?stringconverts a hostname without a port to lowercase ASCII. It returnsNULLif IDN conversion fails.UrlHelper::getAsciiHost(string $url): ?stringextracts the host from a URL and returns it in the same form. It returnsNULLif the URL has no host or if extraction or conversion fails.
Use these methods when a configured hostname and the host in a URL may use different spellings. For example:
use Drupal\Component\Utility\UrlHelper;
$configured_host = UrlHelper::toAsciiHost('café.example');
$url_host = UrlHelper::getAsciiHost('https://xn--caf-dma.example:8080/path');
$same_host = $configured_host !== NULL && $configured_host === $url_host;
Sites using domain-based language negotiation
Administrators can enter a language domain in either spelling. If French is configured for café.example, a request for xn--caf-dma.example selects French. Links generated for French on that host can remain relative. The form preserves the spelling entered by the administrator.
Earlier versions allowed equivalent domains to be assigned to different languages. Existing assignments continue to work after an update. For example, if one language has EXAMPLE.org and another has example.org, a request for example.org still selects the exact match, even if Drupal encounters it second.
When the language negotiation form is saved, each non-empty domain must now be unique after conversion to lowercase ASCII. If the form reports a conflict, choose which language should keep the hostname and update the other assignment before saving.