mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-15 00:27:43 +01:00
nip05: identifier to url.
This commit is contained in:
@@ -95,3 +95,11 @@ func NormalizeIdentifier(fullname string) string {
|
|||||||
|
|
||||||
return fullname
|
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])
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ func TestQuery(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
pp, err := QueryIdentifier(context.Background(), test.input)
|
pp, err := QueryIdentifier(context.Background(), test.input)
|
||||||
if test.expectError {
|
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 {
|
} else {
|
||||||
assert.NoError(t, err, "Did not expect error 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)
|
assert.Equal(t, test.expectedKey, pp.PublicKey, "for input: %s", test.input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user