NIP-19: Add nrelay encoding and decoding

This commit is contained in:
Alejandro Gomez
2023-04-14 17:46:06 +02:00
committed by fiatjaf_
parent f6f5ee8223
commit f17ab41d72
2 changed files with 27 additions and 0 deletions

View File

@@ -100,3 +100,12 @@ test('decode naddr from go-nostr with different TLV ordering', () => {
expect(data.kind).toEqual(30023)
expect(data.identifier).toEqual('banana')
})
test('encode and decode nrelay', () => {
let url = "wss://relay.nostr.example"
let nrelay = nip19.nrelayEncode(url)
expect(nrelay).toMatch(/nrelay1\w+/)
let {type, data} = nip19.decode(nrelay)
expect(type).toEqual('nrelay')
expect(data).toEqual(url)
})