@@ -23,6 +23,9 @@ const (
23
23
// FCMScheme is the scheme used for Firebase Cloud Messaging identifiers
24
24
FCMScheme string = "fcm"
25
25
26
+ // FreshChatScheme is the scheme used for FreshChat Cloud Messaging identifiers
27
+ FreshChatScheme string = "freshchat"
28
+
26
29
// JiochatScheme is the scheme used for Jiochat identifiers
27
30
JiochatScheme string = "jiochat"
28
31
@@ -60,6 +63,7 @@ var ValidSchemes = map[string]bool{
60
63
ExternalScheme : true ,
61
64
FacebookScheme : true ,
62
65
FCMScheme : true ,
66
+ FreshChatScheme : true ,
63
67
JiochatScheme : true ,
64
68
LineScheme : true ,
65
69
TelegramScheme : true ,
@@ -84,6 +88,7 @@ var emailRegex = regexp.MustCompile(`^[^\s@]+@[^\s@]+$`)
84
88
var viberRegex = regexp .MustCompile (`^[a-zA-Z0-9_=/+]{1,24}$` )
85
89
var lineRegex = regexp .MustCompile (`^[a-zA-Z0-9_]{1,36}$` )
86
90
var allDigitsRegex = regexp .MustCompile (`^[0-9]+$` )
91
+ 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}$` )
87
92
88
93
// URN represents a Universal Resource Name, we use this for contact identifiers like phone numbers etc..
89
94
type URN string
@@ -249,9 +254,15 @@ func (u URN) Validate() error {
249
254
if ! allDigitsRegex .MatchString (path ) {
250
255
return fmt .Errorf ("invalid whatsapp id: %s" , path )
251
256
}
252
- }
253
257
258
+ case FreshChatScheme :
259
+ // validate path and query is a uuid
260
+ if ! freshchatRegex .MatchString (path ) {
261
+ return fmt .Errorf ("invalid freshchat id: %s" , path )
262
+ }
263
+ }
254
264
return nil // anything goes for external schemes
265
+
255
266
}
256
267
257
268
// Scheme returns the scheme portion for the URN
0 commit comments