Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
313 changes: 0 additions & 313 deletions flowsint-api/app/utils.py

This file was deleted.

46 changes: 46 additions & 0 deletions flowsint-core/src/flowsint_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,52 @@ def is_root_domain(domain: str) -> bool:
return False


def get_root_domain(domain: str) -> str:
"""
Extract the root domain from a given domain string.

Args:
domain: The domain string (can be a subdomain or root domain)

Returns:
The root domain (e.g., "example.com" from "sub.example.com" or "www.sub.example.com")
"""
try:
if "://" in domain:
parsed = urlparse(domain)
domain = parsed.hostname or domain

parts = domain.split(".")

common_cc_tlds = [
".co.uk",
".com.au",
".org.uk",
".net.uk",
".gov.uk",
".ac.uk",
".co.nz",
".com.sg",
".co.jp",
".co.kr",
".com.br",
".com.mx",
]

for cc_tld in common_cc_tlds:
if domain.endswith(cc_tld):
if len(parts) >= 3:
return ".".join(parts[-3:])
return domain

if len(parts) >= 2:
return ".".join(parts[-2:])

return domain
except Exception:
return domain


def is_valid_number(phone: str, region: str = "FR") -> bool:
"""
Validates a phone number. Raises InvalidPhoneNumberError if invalid.
Expand Down
5 changes: 5 additions & 0 deletions flowsint-enrichers/src/flowsint_enrichers/_shared/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .dehashed_base import DehashedBase
from .hudsonrock_base import HudsonRockBase
from .asnmap_base import AsnmapBase

__all__ = ["DehashedBase", "HudsonRockBase", "AsnmapBase"]
Loading