From 5913ad55e9038121fe9e2c32ea953b0b95a6b722 Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Mon, 31 Dec 2018 02:07:49 +1030 Subject: [PATCH] Use strings.HasSuffix for IsFqdn (#874) --- defaults.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/defaults.go b/defaults.go index 15fd8c02..c9240fb2 100644 --- a/defaults.go +++ b/defaults.go @@ -4,6 +4,7 @@ import ( "errors" "net" "strconv" + "strings" ) const hexDigit = "0123456789abcdef" @@ -191,11 +192,7 @@ func IsMsg(buf []byte) error { // IsFqdn checks if a domain name is fully qualified. func IsFqdn(s string) bool { - l := len(s) - if l == 0 { - return false - } - return s[l-1] == '.' + return strings.HasSuffix(s, ".") } // IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181.