fix: 🐛
This commit is contained in:
parent
4adae16b80
commit
3395bad78b
1 changed files with 7 additions and 5 deletions
|
|
@ -5,15 +5,17 @@ import { nip19 } from 'nostr-tools'
|
||||||
|
|
||||||
export function parseEditorJsonToText(node?: JSONContent) {
|
export function parseEditorJsonToText(node?: JSONContent) {
|
||||||
const text = _parseEditorJsonToText(node).trim()
|
const text = _parseEditorJsonToText(node).trim()
|
||||||
const regex = /(?:^|\s)(nevent|naddr|nprofile|npub)[a-zA-Z0-9]+/g
|
const regex = /(?:^|\s)(nevent|naddr|nprofile|npub)1[a-zA-Z0-9]+/g
|
||||||
|
|
||||||
return text.replace(regex, (match) => {
|
return text.replace(regex, (match) => {
|
||||||
const _match = match.trim()
|
const trimmed = match.trim()
|
||||||
|
const leadingSpace = match.startsWith(' ') ? ' ' : ''
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nip19.decode(_match)
|
nip19.decode(trimmed)
|
||||||
return `nostr:${_match}`
|
return `${leadingSpace}nostr:${trimmed}`
|
||||||
} catch {
|
} catch {
|
||||||
return _match
|
return match
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue