fix: update regex
This commit is contained in:
parent
13527a3ca7
commit
cbac9c5464
2 changed files with 8 additions and 10 deletions
|
|
@ -5,13 +5,15 @@ import { nip19 } from 'nostr-tools'
|
|||
|
||||
export function parseEditorJsonToText(node?: JSONContent) {
|
||||
const text = _parseEditorJsonToText(node).trim()
|
||||
const regex = /(?<=^|\s)(nevent|naddr|nprofile|npub)[a-zA-Z0-9]+/g
|
||||
const regex = /(?:^|\s)(nevent|naddr|nprofile|npub)[a-zA-Z0-9]+/g
|
||||
|
||||
return text.replace(regex, (match) => {
|
||||
const _match = match.trim()
|
||||
try {
|
||||
nip19.decode(match)
|
||||
return `nostr:${match}`
|
||||
nip19.decode(_match)
|
||||
return `nostr:${_match}`
|
||||
} catch {
|
||||
return match
|
||||
return _match
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue