Use strings.HasSuffix for IsFqdn (#874)

This commit is contained in:
Tom Thorogood 2018-12-31 02:07:49 +10:30 committed by Miek Gieben
parent b0835fab5e
commit 5913ad55e9
1 changed files with 2 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"net" "net"
"strconv" "strconv"
"strings"
) )
const hexDigit = "0123456789abcdef" const hexDigit = "0123456789abcdef"
@ -191,11 +192,7 @@ func IsMsg(buf []byte) error {
// IsFqdn checks if a domain name is fully qualified. // IsFqdn checks if a domain name is fully qualified.
func IsFqdn(s string) bool { func IsFqdn(s string) bool {
l := len(s) return strings.HasSuffix(s, ".")
if l == 0 {
return false
}
return s[l-1] == '.'
} }
// IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181. // IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181.