Skip to content

Commit

Permalink
nip05: identifier to url.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 27, 2024
1 parent 1ac5516 commit a1a4c04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions nip05/nip05.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ func NormalizeIdentifier(fullname string) string {

return fullname
}

func IdentifierToURL(address string) string {
spl := strings.Split(address, "@")
if len(spl) == 1 {
return fmt.Sprintf("https://%s/.well-known/nostr.json?name=_", spl[0])
}
return fmt.Sprintf("https://%s/.well-known/nostr.json?name=%s", spl[1], spl[0])
}
6 changes: 3 additions & 3 deletions nip05/nip05_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func TestQuery(t *testing.T) {
for _, test := range tests {
pp, err := QueryIdentifier(context.Background(), test.input)
if test.expectError {
assert.Error(t, err, "Expected error for input: %s", test.input)
assert.Error(t, err, "expected error for input: %s", test.input)
} else {
assert.NoError(t, err, "Did not expect error for input: %s", test.input)
assert.Equal(t, test.expectedKey, pp.PublicKey, "For input: %s", test.input)
assert.NoError(t, err, "did not expect error for input: %s", test.input)
assert.Equal(t, test.expectedKey, pp.PublicKey, "for input: %s", test.input)
}
}
}

0 comments on commit a1a4c04

Please sign in to comment.