Skip to content

Commit 884adfc

Browse files
committed
fix(auth): remove linebreaks from did lookup
1 parent d69f89e commit 884adfc

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bluesky/auth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func GetUserAuthData(handle string) (*string, *string, error) {
106106
bodyBytes, _ := io.ReadAll(wellKnownDIDResp.Body)
107107
bodyString := string(bodyBytes)
108108

109+
// Remove newline charectors, since it likes to fail the regex with them
110+
bodyString = strings.ReplaceAll(bodyString, "\n", "")
111+
// Check if the body is a DID
109112
if regexp.MustCompile(`^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`).MatchString(bodyString) {
110113
userDID = bodyString
111114
}
@@ -116,6 +119,7 @@ func GetUserAuthData(handle string) (*string, *string, error) {
116119
txts, err := net.LookupTXT(fmt.Sprintf("_atproto.%s", handle))
117120
if err == nil {
118121
for _, txt := range txts {
122+
txt = strings.ReplaceAll(txt, "\n", "")
119123
if regexp.MustCompile(`^did=did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$`).MatchString(txt) {
120124
userDID = txt[4:] // Extract the DID without the 'did=' prefix
121125
break

0 commit comments

Comments
 (0)