Merge pull request #6 from mricim/patch-1

Refactor get_domain_from_fqdn regex to handle both www and root domain
This commit is contained in:
Lázaro Blanc 2023-12-30 20:43:32 +01:00 committed by GitHub
commit ba769cd06e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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