-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for email links #66
Conversation
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits, only otherwise LGTM! Thanks
if checkEmail(strings.TrimSpace(email[1])) { | ||
return | ||
} | ||
v.destFutures[k].resultFn = func() error { return errors.New("email not valid " + dest) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v.destFutures[k].resultFn = func() error { return errors.New("email not valid " + dest) } | |
v.destFutures[k].resultFn = func() error { return errors.Errors("provided mailto link is not a valid email, got %v", dest) } |
if strings.HasPrefix(dest, "mailto:") { | ||
email := strings.Split(dest, "mailto:") | ||
if checkEmail(strings.TrimSpace(email[1])) { | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if strings.HasPrefix(dest, "mailto:") { | |
email := strings.Split(dest, "mailto:") | |
if checkEmail(strings.TrimSpace(email[1])) { | |
return | |
} | |
if email := strings.TrimPrefix(dest, "mailto:"); email != dest { | |
if checkEmail(email) { | |
return | |
} |
@@ -304,6 +315,26 @@ func (v *validator) visit(filepath string, dest string, lineNumbers string) { | |||
} | |||
} | |||
|
|||
// checkEmail checks email structure and domain. | |||
func checkEmail(email string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func checkEmail(email string) bool { | |
func isValidEmail(email string) bool { |
Check is not very verbose what exactly we are checking for
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! and tests!! Amazing 💪🏽
This PR adds checks for
mailto:
email links like here. It validates email using regex as specified here and also checks if email has valid domain usingnet.LookupMX
. Fixes #65.