mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-15 17:16:59 +02:00
Another small fix in domain check
This commit is contained in:
parent
fc604786cf
commit
8ca5d5a53d
2 changed files with 22 additions and 7 deletions
|
@ -359,10 +359,19 @@ function extractDomainAndTLD($urlString) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Use the PHP Domain Parser library for real TLDs
|
||||||
|
try {
|
||||||
// Use the PHP Domain Parser library for real TLDs
|
// Use the PHP Domain Parser library for real TLDs
|
||||||
$tlds = TopLevelDomains::fromString($fileContent);
|
$tlds = TopLevelDomains::fromString($fileContent);
|
||||||
$domain = Domain::fromIDNA2008($host);
|
$domain = Domain::fromIDNA2008($host);
|
||||||
$resolvedTLD = $tlds->resolve($domain)->suffix()->toString();
|
$resolvedTLD = $tlds->resolve($domain)->suffix()->toString();
|
||||||
|
} catch (\Pdp\Exception $e) { // Catch domain parser exceptions
|
||||||
|
$_SESSION['slimFlash']['error'][] = 'Domain parsing error: ' . $e->getMessage();
|
||||||
|
return ['error' => 'Domain parsing error: ' . $e->getMessage()];
|
||||||
|
} catch (\Exception $e) { // Catch any other unexpected exceptions
|
||||||
|
$_SESSION['slimFlash']['error'][] = 'Unexpected error: ' . $e->getMessage();
|
||||||
|
return ['error' => 'Unexpected error: ' . $e->getMessage()];
|
||||||
|
}
|
||||||
|
|
||||||
// Handle cases with multi-level TLDs
|
// Handle cases with multi-level TLDs
|
||||||
$possibleTLDs = [];
|
$possibleTLDs = [];
|
||||||
|
|
|
@ -300,10 +300,16 @@ function extractDomainAndTLD($urlString) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Use the PHP Domain Parser library for real TLDs
|
// Use the PHP Domain Parser library for real TLDs
|
||||||
$tlds = TopLevelDomains::fromString($fileContent);
|
$tlds = TopLevelDomains::fromString($fileContent);
|
||||||
$domain = Domain::fromIDNA2008($host);
|
$domain = Domain::fromIDNA2008($host);
|
||||||
$resolvedTLD = $tlds->resolve($domain)->suffix()->toString();
|
$resolvedTLD = $tlds->resolve($domain)->suffix()->toString();
|
||||||
|
} catch (\Pdp\Exception $e) { // Catch domain parser exceptions
|
||||||
|
throw new \Exception('Domain parsing error: ' . $e->getMessage());
|
||||||
|
} catch (\Exception $e) { // Catch any other unexpected exceptions
|
||||||
|
throw new \Exception('Unexpected error: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// Handle cases with multi-level TLDs
|
// Handle cases with multi-level TLDs
|
||||||
$possibleTLDs = [];
|
$possibleTLDs = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue