Discover books, shows, and movies at your level. Track your progress by filling your Shelf with what you find, and share with other language learners. *No dusting required. shlf.space
at master 20 lines 467 B view raw
1package atproto 2 3import ( 4 "regexp" 5) 6 7var ( 8 // ref: https://atproto.com/specs/handle 9 handleRegex = regexp.MustCompile(`^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$`) 10 // ref: https://atproto.com/specs/did 11 didRegex = regexp.MustCompile(`^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`) 12) 13 14func IsHandle(s string) bool { 15 return handleRegex.MatchString(s) 16} 17 18func IsDid(s string) bool { 19 return didRegex.MatchString(s) 20}