mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-22 18:45:59 +02:00
Some fixes for domain create and hosts
This commit is contained in:
parent
918afc8473
commit
abde99e73e
2 changed files with 54 additions and 20 deletions
|
@ -586,4 +586,20 @@ function toPunycode($value) {
|
|||
function toUnicode($value) {
|
||||
// Convert from Punycode to UTF-8 if it's a valid IDN format
|
||||
return (strpos($value, 'xn--') === 0) ? idn_to_utf8($value, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46) : $value;
|
||||
}
|
||||
|
||||
function extractHostTLD(string $hostname): array
|
||||
{
|
||||
$parts = explode('.', $hostname);
|
||||
|
||||
if (count($parts) < 2) {
|
||||
// Invalid hostname; return empty values
|
||||
return ['host' => '', 'tld' => ''];
|
||||
}
|
||||
|
||||
// Extract host and TLD
|
||||
$tld = array_pop($parts); // Get the last part as TLD
|
||||
$host = array_pop($parts); // Get the second last part as host
|
||||
|
||||
return ['host' => $host, 'tld' => $tld];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue