From db8ce0e62568118577db0dfee8f2eb684095aa22 Mon Sep 17 00:00:00 2001 From: Onur Cinar Date: Wed, 21 Jun 2023 18:26:43 -0700 Subject: [PATCH] Go critic identified issues. Fixes #82 (#87) --- email.go | 4 ++-- fqdn.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 {