diff --git a/pkg/ddns/ddns.go b/pkg/ddns/ddns.go index 56d1a5c..59f0d3d 100644 --- a/pkg/ddns/ddns.go +++ b/pkg/ddns/ddns.go @@ -108,7 +108,7 @@ func splitDomainSOA(domain string) (prefix string, zone string, err error) { if len(r.Answer) > 0 { if soa, ok := r.Answer[0].(*dns.SOA); ok { zone = soa.Hdr.Name - prefix = domain[:len(domain)-len(zone)-1] + prefix = libdns.RelativeName(domain, zone) return } } diff --git a/pkg/ddns/ddns_test.go b/pkg/ddns/ddns_test.go index 1906133..9761f1c 100644 --- a/pkg/ddns/ddns_test.go +++ b/pkg/ddns/ddns_test.go @@ -27,6 +27,11 @@ func TestSplitDomainSOA(t *testing.T) { zone: "example.com.", prefix: "abc", }, + { + domain: "example.com", + zone: "example.com.", + prefix: "", + }, } for _, c := range cases {