Skip to content

Commit

Permalink
fix system generated bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbr0wn authored and alexopenline committed Nov 21, 2024
1 parent 0162c53 commit ed774c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/syntax/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func hasMultipleNumericSegments(username string) bool {
func isCommonNamePattern(username string) bool {
namePatterns := []*regexp.Regexp{
regexp.MustCompile(`^[a-z]+\.[a-z]+\d{0,4}$`), // john.doe123
regexp.MustCompile(`^[a-z]+\_[a-z]+\d{0,4}$`), // john.doe123
regexp.MustCompile(`^[a-z]+\.[a-z]\.[a-z]+$`), // john.m.doe
regexp.MustCompile(`^[a-z]+\.[a-z]+\.[a-z]+$`), // john.michael.doe
regexp.MustCompile(`^[a-z]+[a-z0-9]{0,4}$`), // johndoe, john123
Expand Down
18 changes: 17 additions & 1 deletion mailvalidate/email_syntax_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package mailvalidate_test
import (
"testing"

"github.com/customeros/mailsherpa/mailvalidate"
"github.com/stretchr/testify/assert"

"github.com/customeros/mailsherpa/mailvalidate"
)

func TestValidateEmailSyntax(t *testing.T) {
Expand Down Expand Up @@ -80,6 +81,21 @@ func TestValidateEmailSyntax(t *testing.T) {
expected: mailvalidate.SyntaxValidation{},
description: "Invalid email should return empty validation struct",
},
{
name: "Underscore Username",
email: "bob_smith@google.com",
expected: mailvalidate.SyntaxValidation{
IsValid: true,
User: "bob_smith",
Domain: "google.com",
CleanEmail: "bob_smith@google.com",
IsRoleAccount: false,
IsFreeAccount: false,
IsSystemGenerated: false,
Error: "",
},
description: "Underscores in username should be supported",
},
{
name: "Mixed Case with Emoji Email",
email: "Rob.Name😆@Gmail.com",
Expand Down

0 comments on commit ed774c2

Please sign in to comment.