enhanced domain extraction and bulk import functionality

This commit is contained in:
2024-07-30 15:23:41 +02:00
parent 2e13bf4f71
commit 1d40161f27
3 changed files with 188 additions and 0 deletions

View File

@@ -25,6 +25,20 @@ function extractDomain(url: string): string {
domain = domain.replace(/^www\./, '')
domain = domain.replace(/^m\./, '')
domain = domain.replace(/^mobile\./, '')
domain = domain.replace(/^amp\./, '')
// Handle subdomains for known patterns - extract main domain for common TLDs
if (domain.includes('.')) {
const parts = domain.split('.')
if (parts.length > 2) {
const tld = parts[parts.length - 1]
const sld = parts[parts.length - 2]
// Extract main domain for common TLDs
if (['com', 'org', 'net', 'sk', 'cz', 'hu', 'pl', 'eu', 'info'].includes(tld)) {
domain = `${sld}.${tld}`
}
}
}
return domain
} catch {