From ca62996a56f63b655ebb3ceccf55d038e6252e59 Mon Sep 17 00:00:00 2001 From: mricim <56126432+mricim@users.noreply.github.com> Date: Sat, 30 Dec 2023 20:30:59 +0100 Subject: [PATCH] Refactor get_domain_from_fqdn regex to handle both www and root domain This commit addresses an issue where the script was expecting the domain to include the "www" prefix for proper zone identification. The regex in get_domain_from_fqdn has been modified to make the subdomain part optional, allowing it to handle both domains with "www" and root domains without "www". These changes were necessary to ensure the script works seamlessly with both www and root domains, providing more flexibility in DNS record handling. Testing has been performed, and the script now successfully identifies and updates DNS records for domains with or without the "www" prefix. --- ionos_dyndns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ionos_dyndns.py b/ionos_dyndns.py index ddabf3b..1db893c 100644 --- a/ionos_dyndns.py +++ b/ionos_dyndns.py @@ -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