Skip to content

Commit

Permalink
Add email component to webchat URNs
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 23, 2024
1 parent 9182672 commit 1387ca2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion urns/urns.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var viberRegex = regexp.MustCompile(`^[a-zA-Z0-9_=/+]{1,24}$`)
var lineRegex = regexp.MustCompile(`^[a-zA-Z0-9_]{1,36}$`)
var allDigitsRegex = regexp.MustCompile(`^[0-9]+$`)
var freshchatRegex = regexp.MustCompile(`^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$`)
var webchatRegex = regexp.MustCompile(`^[a-zA-Z0-9]{24}$`)
var webchatRegex = regexp.MustCompile(`^[a-zA-Z0-9]{24}(:[^\s@]+@[^\s@]+)?$`)

// URN represents a Universal Resource Name, we use this for contact identifiers like phone numbers etc..
type URN string
Expand Down
2 changes: 2 additions & 0 deletions urns/urns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ func TestValidate(t *testing.T) {
{"slack:U0123ABCDEF", ""},

{"webchat:aA3456789012345678901234", ""},
{"webchat:aA3456789012345678901234:[email protected]", ""},
{"webchat:1234567890123456789", "invalid webchat id"},
{"webchat:12345678901234567890123$", "invalid webchat id"},
{"webchat:aA3456789012345678901234:@@$", "invalid webchat id"},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 1387ca2

Please sign in to comment.