diff options
Diffstat (limited to 'plugin/pkg')
-rw-r--r-- | plugin/pkg/dnsutil/join.go | 8 | ||||
-rw-r--r-- | plugin/pkg/dnsutil/join_test.go | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/plugin/pkg/dnsutil/join.go b/plugin/pkg/dnsutil/join.go index 515bf3dad..b3a40db42 100644 --- a/plugin/pkg/dnsutil/join.go +++ b/plugin/pkg/dnsutil/join.go @@ -8,12 +8,10 @@ import ( // Join joins labels to form a fully qualified domain name. If the last label is // the root label it is ignored. Not other syntax checks are performed. -func Join(labels []string) string { +func Join(labels ...string) string { ll := len(labels) if labels[ll-1] == "." { - s := strings.Join(labels[:ll-1], ".") - return dns.Fqdn(s) + return strings.Join(labels[:ll-1], ".") + "." } - s := strings.Join(labels, ".") - return dns.Fqdn(s) + return dns.Fqdn(strings.Join(labels, ".")) } diff --git a/plugin/pkg/dnsutil/join_test.go b/plugin/pkg/dnsutil/join_test.go index 26eeb5897..1a50a3c99 100644 --- a/plugin/pkg/dnsutil/join_test.go +++ b/plugin/pkg/dnsutil/join_test.go @@ -9,11 +9,12 @@ func TestJoin(t *testing.T) { }{ {[]string{"bla", "bliep", "example", "org"}, "bla.bliep.example.org."}, {[]string{"example", "."}, "example."}, + {[]string{"example", "org."}, "example.org."}, // technically we should not be called like this. {[]string{"."}, "."}, } for i, tc := range tests { - if x := Join(tc.in); x != tc.out { + if x := Join(tc.in...); x != tc.out { t.Errorf("Test %d, expected %s, got %s", i, tc.out, x) } } |