IsSubDomain docs
Improve the docs a little and add a test for when the child and parent are equal.
This commit is contained in:
parent
b5f8285e2a
commit
dd83d5cbcf
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue