If someone gives us a hex key (like nostr.band does), handle it instead of crashing

This commit is contained in:
Jonathan Staab 2023-03-23 15:45:55 -05:00
parent fe990f7d26
commit 20d61ed6dc

View File

@ -130,6 +130,10 @@ export const asDisplayEvent = event =>
({replies: [], reactions: [], zaps: [], ...event} as DisplayEvent)
export const toHex = (data: string): string | null => {
if (data.match(/[a-zA-Z0-9]{64}/)) {
return data
}
try {
return nip19.decode(data).data as string
} catch (e) {