mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-18 11:13:30 +00:00
fix app crash issue
This commit is contained in:
parent
95cf3f60f3
commit
c93989237a
@ -74,33 +74,45 @@ export function parser(content: string) {
|
|||||||
// nostr account references (depreciated)
|
// nostr account references (depreciated)
|
||||||
if (word.startsWith('@npub1')) {
|
if (word.startsWith('@npub1')) {
|
||||||
const npub = word.replace('@', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const npub = word.replace('@', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
return word.replace(
|
try {
|
||||||
word,
|
const pubkey = nip19.decode(npub).data as string;
|
||||||
`<MentionUser pubkey='${nip19.decode(npub).data as string}' />`
|
return word.replace(word, `<MentionUser pubkey='${pubkey}' />`);
|
||||||
);
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nostr account references
|
// nostr account references
|
||||||
if (word.startsWith('nostr:npub1') || word.startsWith('npub1')) {
|
if (word.startsWith('nostr:npub1') || word.startsWith('npub1')) {
|
||||||
const npub = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const npub = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
return word.replace(
|
try {
|
||||||
word,
|
const pubkey = nip19.decode(npub).data as string;
|
||||||
`<MentionUser pubkey='${nip19.decode(npub).data as string}' />`
|
return word.replace(word, `<MentionUser pubkey='${pubkey}' />`);
|
||||||
);
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nostr profile references
|
// nostr profile references
|
||||||
if (word.startsWith('nostr:nprofile1') || word.startsWith('nprofile1')) {
|
if (word.startsWith('nostr:nprofile1') || word.startsWith('nprofile1')) {
|
||||||
const nprofile = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const nprofile = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
const decoded = nip19.decode(nprofile).data as ProfilePointer;
|
try {
|
||||||
return word.replace(word, `<MentionUser pubkey='${decoded.pubkey}' />`);
|
const decoded = nip19.decode(nprofile).data as ProfilePointer;
|
||||||
|
return word.replace(word, `<MentionUser pubkey='${decoded.pubkey}' />`);
|
||||||
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nostr address references
|
// nostr address references
|
||||||
if (word.startsWith('nostr:naddr1') || word.startsWith('naddr1')) {
|
if (word.startsWith('nostr:naddr1') || word.startsWith('naddr1')) {
|
||||||
const naddr = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const naddr = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
const decoded = nip19.decode(naddr).data as AddressPointer;
|
try {
|
||||||
return word.replace(word, `<MentionUser pubkey='${decoded.pubkey}' />`);
|
const decoded = nip19.decode(naddr).data as AddressPointer;
|
||||||
|
return word.replace(word, `<MentionUser pubkey='${decoded.pubkey}' />`);
|
||||||
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// lightning invoice
|
// lightning invoice
|
||||||
@ -111,16 +123,25 @@ export function parser(content: string) {
|
|||||||
// nostr note references
|
// nostr note references
|
||||||
if (word.startsWith('nostr:note1') || word.startsWith('note1')) {
|
if (word.startsWith('nostr:note1') || word.startsWith('note1')) {
|
||||||
const note = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const note = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
richContent.notes.push(nip19.decode(note).data as string);
|
try {
|
||||||
return word.replace(word, '');
|
const eventId = nip19.decode(note).data as string;
|
||||||
|
richContent.notes.push(eventId);
|
||||||
|
return word.replace(word, '');
|
||||||
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nostr event references
|
// nostr event references
|
||||||
if (word.startsWith('nostr:nevent1') || word.startsWith('nevent1')) {
|
if (word.startsWith('nostr:nevent1') || word.startsWith('nevent1')) {
|
||||||
const nevent = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
const nevent = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, '');
|
||||||
const decoded = nip19.decode(nevent).data as EventPointer;
|
try {
|
||||||
richContent.notes.push(decoded.id);
|
const decoded = nip19.decode(nevent).data as EventPointer;
|
||||||
return word.replace(word, '');
|
richContent.notes.push(decoded.id);
|
||||||
|
return word.replace(word, '');
|
||||||
|
} catch {
|
||||||
|
return word;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return word;
|
return word;
|
||||||
|
Loading…
Reference in New Issue
Block a user