lowercase the names

This commit is contained in:
Miek Gieben 2012-09-04 20:08:55 +02:00
parent e4f67647b9
commit a2d98be202
3 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package dns
import (
"net"
"strconv"
"strings"
)
const hexDigit = "0123456789abcdef"
@ -215,7 +216,7 @@ func IsDomainName(s string) (uint8, uint8, bool) { // copied from net package.
// IsSubDomain checks if child is indeed a child of the parent.
func IsSubDomain(parent, child string) bool {
// Entire child is contained in parent
return CompareLabels(parent, child) == LenLabels(parent)
return CompareLabels(strings.ToLower(parent), strings.ToLower(child)) == LenLabels(parent)
}
// IsFqdn checks if a domain name is fully qualified.

View File

@ -34,7 +34,8 @@ func SplitLabels(s string) []string {
// CompareLabels compares the strings s1 and s2 and
// returns how many labels they have in common starting from the right.
// The comparison stops at the first inequality.
// The comparison stops at the first inequality. The labels are not downcased
// before the comparison.
//
// 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

View File

@ -90,6 +90,10 @@ func toRadixName(d string) string {
}
s := ""
for _, l := range SplitLabels(d) {
if s == "" {
s = strings.ToLower(l) + s
continue
}
s = strings.ToLower(l) + "." + s
}
return s