IsSubDomain docs

Improve the docs a little and add a test for when the child and parent
are equal.
This commit is contained in:
Miek Gieben 2016-04-12 22:05:53 +01:00
parent b5f8285e2a
commit dd83d5cbcf
2 changed files with 5 additions and 4 deletions

View File

@ -167,8 +167,8 @@ func IsDomainName(s string) (labels int, ok bool) {
return labels, err == nil
}
// IsSubDomain checks if child is indeed a child of the parent. Both child and
// parent are *not* downcased before doing the comparison.
// IsSubDomain checks if child is indeed a child of the parent. If child and parent
// are the same domain true is returned as well.
func IsSubDomain(parent, child string) bool {
// Entire child is contained in parent
return CompareDomainName(parent, child) == CountLabel(parent)

View File

@ -99,8 +99,9 @@ func TestPackUnpack3(t *testing.T) {
func TestBailiwick(t *testing.T) {
yes := map[string]string{
"miek.nl": "ns.miek.nl",
".": "miek.nl",
"miek1.nl": "miek1.nl",
"miek.nl": "ns.miek.nl",
".": "miek.nl",
}
for parent, child := range yes {
if !IsSubDomain(parent, child) {