diff --git a/email.go b/email.go index 4459824..1d1fb53 100644 --- a/email.go +++ b/email.go @@ -16,7 +16,7 @@ const ResultNotEmail = "NOT_EMAIL" const ipV6Prefix = "[IPv6:" // notQuotedChars is the valid not quoted characters. -var notQuotedChars = regexp.MustCompile("[a-zA-Z0-9!#$%&'*+-/=?^_`{|}~]") +var notQuotedChars = regexp.MustCompile("[a-zA-Z0-9!#$%&'*\\+\\-/=?^_`{|}~]") // IsEmail checks if the given string is an email address. func IsEmail(email string) Result { @@ -33,7 +33,7 @@ func IsEmail(email string) Result { user := email[:atIndex] // Cannot be empty user - if len(user) == 0 || len(user) > 64 { + if user == "" || len(user) > 64 { return ResultNotEmail } diff --git a/fqdn.go b/fqdn.go index 1112dc0..4ba200e 100644 --- a/fqdn.go +++ b/fqdn.go @@ -13,7 +13,7 @@ const CheckerFqdn = "fqdn" const ResultNotFqdn = "NOT_FQDN" // Valid characters excluding full-width characters. -var fqdnValidChars = regexp.MustCompile("^[a-z0-9\u00a1-\uff00\uff06-\uffff-]+$") +var fqdnValidChars = regexp.MustCompile("^[a-z0-9\u00a1-\uff00\uff06-\uffff\\-]+$") // IsFqdn checks if the given string is a fully qualified domain name. func IsFqdn(domain string) Result {