mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-17 01:57:00 +02:00
parent
82f9581c44
commit
bd5ada89b9
6 changed files with 30 additions and 23 deletions
|
@ -231,6 +231,8 @@ function validate_label($label, $pdo) {
|
|||
}
|
||||
|
||||
function extractDomainAndTLD($urlString) {
|
||||
global $c;
|
||||
|
||||
$cachePath = '/var/www/cp/cache'; // Cache directory
|
||||
$adapter = new LocalFilesystemAdapter($cachePath, null, LOCK_EX);
|
||||
$filesystem = new Filesystem($adapter);
|
||||
|
@ -239,17 +241,17 @@ function extractDomainAndTLD($urlString) {
|
|||
$cachedFile = $cache->getItem($cacheKey);
|
||||
$fileContent = $cachedFile->get();
|
||||
|
||||
// Define a list of fake TLDs used in your QA environment
|
||||
$fakeTlds = ['test', 'xx'];
|
||||
// Load a list of test TLDs used in your QA environment
|
||||
$testTlds = explode(',', $c['test_tlds']);
|
||||
|
||||
// Parse the URL to get the host
|
||||
$parts = parse_url($urlString);
|
||||
$host = $parts['host'] ?? $urlString;
|
||||
|
||||
// Check if the TLD is a known fake TLD
|
||||
foreach ($fakeTlds as $fakeTld) {
|
||||
if (str_ends_with($host, ".$fakeTld")) {
|
||||
// Handle the fake TLD case
|
||||
// Check if the TLD is a known test TLD
|
||||
foreach ($testTlds as $testTld) {
|
||||
if (str_ends_with($host, "$testTld")) {
|
||||
// Handle the test TLD case
|
||||
$hostParts = explode('.', $host);
|
||||
$tld = array_pop($hostParts);
|
||||
$sld = array_pop($hostParts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue