Merge pull request #5 from rhigginsDE/main

Update def get_domain_from_fqdn(fqdn)
This commit is contained in:
Lázaro Blanc 2023-12-02 00:10:36 +01:00 committed by GitHub
commit 532dcad35b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -135,8 +135,10 @@ def main():
def get_domain_from_fqdn(fqdn):
regex = r"(?:(?:\w|-)+\.)+(\w+\.\w+)$"
return re.search(regex, fqdn, re.IGNORECASE).group(1)
# Place the hyphen at the start of the character class to avoid misinterpretation
regex = r"(?:(?:[\w-]+)\.)+([\w-]+\.\w+)$"
match = re.search(regex, fqdn, re.IGNORECASE)
return match.group(1) if match else None
def get_ipv4_address():