···55 "strings"66)7788+var (99+ 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])?$`)1010+ didRegex = regexp.MustCompile(`^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`)1111+)1212+813func IsHandleNoAt(s string) bool {914 // ref: https://atproto.com/specs/handle1010- re := 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])?$`)1111- return re.MatchString(s)1515+ return handleRegex.MatchString(s)1216}13171418func UnflattenDid(s string) string {···3329 // Reconstruct as a standard DID format using Replace3430 // Example: "did-plc-xyz-abc" becomes "did:plc:xyz-abc"3531 reconstructed := strings.Replace(s, "-", ":", 2)3636- re := regexp.MustCompile(`^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`)37323838- return re.MatchString(reconstructed)3333+ return didRegex.MatchString(reconstructed)3934}40354136// FlattenDid converts a DID to a flattened format.···49465047// IsDid checks if the given string is a standard DID.5148func IsDid(s string) bool {5252- re := regexp.MustCompile(`^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`)5353- return re.MatchString(s)4949+ return didRegex.MatchString(s)5450}