From 84e9295e47292dc92c4352a877af9c5eb8d8077f Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 27 Feb 2016 13:22:01 +0000 Subject: [PATCH] Improve docs on the label functions Explicitly mention that the domain s must be valid before given it to these functions. Fixes: 306 --- labels.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/labels.go b/labels.go index b1ee85ac..cb549fc6 100644 --- a/labels.go +++ b/labels.go @@ -8,6 +8,7 @@ package dns // The root label (.) returns nil. Note that using // strings.Split(s) will work in most cases, but does not handle // escaped dots (\.) for instance. +// s must be a syntactically valid domain name, see IsDomainName. func SplitDomainName(s string) (labels []string) { if len(s) == 0 { return nil @@ -46,6 +47,8 @@ func SplitDomainName(s string) (labels []string) { // // www.miek.nl. and miek.nl. have two labels in common: miek and nl // www.miek.nl. and www.bla.nl. have one label in common: nl +// +// s1 and s2 must be syntactically valid domain names. func CompareDomainName(s1, s2 string) (n int) { s1 = Fqdn(s1) s2 = Fqdn(s2) @@ -86,6 +89,7 @@ func CompareDomainName(s1, s2 string) (n int) { } // CountLabel counts the the number of labels in the string s. +// s must be a syntactically valid domain name. func CountLabel(s string) (labels int) { if s == "." { return @@ -103,8 +107,8 @@ func CountLabel(s string) (labels int) { // Split splits a name s into its label indexes. // www.miek.nl. returns []int{0, 4, 9}, www.miek.nl also returns []int{0, 4, 9}. -// .www.miek.nl. returns []int{0, 1, 5, 10} -// The root name (.) returns nil. Also see SplitDomainName. +// The root name (.) returns nil. Also see SplitDomainName. +// s must be a syntactically valid domain name. func Split(s string) []int { if s == "." { return nil