Fix event mention bug (#421)
* only replace valid note IDs * render empty string if no ref.Event
This commit is contained in:
parent
1357b7a903
commit
3dccf21d2c
@ -81,13 +81,15 @@ export default function Text({ content, tags, creator }: TextProps) {
|
|||||||
}
|
}
|
||||||
case "e": {
|
case "e": {
|
||||||
const eText = hexToBech32("note", ref.Event).substring(0, 12);
|
const eText = hexToBech32("note", ref.Event).substring(0, 12);
|
||||||
return (
|
return ref.Event ? (
|
||||||
<Link
|
<Link
|
||||||
to={eventLink(ref.Event ?? "")}
|
to={eventLink(ref.Event)}
|
||||||
onClick={e => e.stopPropagation()}
|
onClick={e => e.stopPropagation()}
|
||||||
state={{ from: location.pathname }}>
|
state={{ from: location.pathname }}>
|
||||||
#{eText}
|
#{eText}
|
||||||
</Link>
|
</Link>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case "t": {
|
case "t": {
|
||||||
|
@ -76,7 +76,7 @@ export default function useEventPublisher() {
|
|||||||
};
|
};
|
||||||
const content = msg
|
const content = msg
|
||||||
.replace(/@npub[a-z0-9]+/g, replaceNpub)
|
.replace(/@npub[a-z0-9]+/g, replaceNpub)
|
||||||
.replace(/note[a-z0-9]+/g, replaceNoteId)
|
.replace(/note1[acdefghjklmnpqrstuvwxyz023456789]{58}/g, replaceNoteId)
|
||||||
.replace(HashtagRegex, replaceHashtag);
|
.replace(HashtagRegex, replaceHashtag);
|
||||||
ev.Content = content;
|
ev.Content = content;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user