Browse Source

fix: neventOrNoteToHexId error handling

to prevent svelte 500 error when bech32 invalid
master
DanConwayDev 2 years ago
parent
commit
c8335a0b5d
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 3
      src/lib/components/repo/utils.ts

3
src/lib/components/repo/utils.ts

@ -96,8 +96,11 @@ export const aToNaddr = ( @@ -96,8 +96,11 @@ export const aToNaddr = (
}
export const neventOrNoteToHexId = (s: string): string | undefined => {
try {
const decoded = nip19.decode(s)
if (decoded.type === 'note') return decoded.data
else if (decoded.type === 'nevent') return decoded.data.id
}
catch {}
return undefined
}

Loading…
Cancel
Save