From fed7baa20ee3a2f454e2b54cdc7ca959453070b4 Mon Sep 17 00:00:00 2001 From: niten Date: Sat, 7 Oct 2023 10:00:18 -0700 Subject: [PATCH] Try specifying the characters --- zone-to-zonefile.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/zone-to-zonefile.nix b/zone-to-zonefile.nix index 548ffad..67c8048 100644 --- a/zone-to-zonefile.nix +++ b/zone-to-zonefile.nix @@ -57,12 +57,14 @@ let isNotNull = o: !isNull o; hostToFqdn = host: - if isNotNull (builtins.match "[^.]+\\.$" host) then - host - else if isNotNull (builtins.match "([^.]+\\.)+[^.]+$" host) then - "${host}." - else if (hasAttr host zone.hosts) then + let hostChars = "[a-zA-Z0-9_-]"; + in if (hasAttr host zone.hosts) then "${host}.${domain}." + else if isNotNull (builtins.match "${hostChars}+\\.$" host) then + host + else if isNotNull + (builtins.match "(${hostChars}+\\.)+${hostChars}+$" host) then + "${host}." else abort "unrecognized hostname: ${host}";