appview: repo: trim leading @ from collaborator's handle #417

merged
opened by bad-example.com targeting master from bad-example.com/core: fix/contributor-handle

The "add collaborator" form currently fails if you submit a handle like @example.com, since the identity gets forwarded eventually directly to Bluesky's identity parse, which does not accept the @ prefix for handles.

This change is targetted to only fix that one form.

I do think it would be nice to put it in idresolver's ResolveIdent instead, but a change there seems like it could have wide effect across the app that i'm not equipped to test. Searching for strings.TrimPrefix shows manual stripping of @-prefixes in middleware, oauth, avatars, and keys, so I figure this direct change is consistent?

(I did not do a thorough survey of other handle handling that might also be missing @-stripping.)

Changed files
+3
appview
repo
+3
appview/repo/repo.go
···
return
}
+
// remove a single leading `@`, to make @handle work with ResolveIdent
+
collaborator = strings.TrimPrefix(collaborator, "@")
+
collaboratorIdent, err := rp.idResolver.ResolveIdent(r.Context(), collaborator)
if err != nil {
fail(fmt.Sprintf("'%s' is not a valid DID/handle.", collaborator), err)