Skip to content

Commit

Permalink
use tldextract to get domain root
Browse files Browse the repository at this point in the history
  • Loading branch information
GiviMAD committed Dec 18, 2023
1 parent 45b499f commit 6704722
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lexicon/_private/providers/godaddy.py
Expand Up @@ -12,6 +12,8 @@
from lexicon.exceptions import LexiconError
from lexicon.interfaces import Provider as BaseProvider

import tldextract

LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -299,10 +301,8 @@ def _identifier(record):

def get_root_domain_name(self):
# Remove the subdomains parts if any
domain = self.domain
domain_parts = domain.split(".")
n_parts = len(domain_parts)
return domain_parts[n_parts - 2] + "." + domain_parts[n_parts - 1]
extracted = tldextract.extract(domain)
return extracted.domain + "." + extracted.suffix

def _request(self, action="GET", url="/", data=None, query_params=None):
# When editing DNS zone, API is unavailable for few seconds
Expand Down

0 comments on commit 6704722

Please sign in to comment.