diff --git a/README.md b/README.md index d3431a5..ce7c1a2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Snort supports the following NIP's - [x] NIP-05: Mapping Nostr keys to DNS-based internet identifiers - [ ] NIP-06: Basic key derivation from mnemonic seed phrase - [x] NIP-07: `window.nostr` capability for web browsers -- [ ] NIP-08: Handling Mentions +- [x] NIP-08: Handling Mentions - [x] NIP-09: Event Deletion - [x] NIP-10: Conventions for clients' use of `e` and `p` tags in text events - [ ] NIP-11: Relay Information Document diff --git a/src/Feed/EventPublisher.ts b/src/Feed/EventPublisher.ts index b62d688..a4e47f2 100644 --- a/src/Feed/EventPublisher.ts +++ b/src/Feed/EventPublisher.ts @@ -54,14 +54,25 @@ export default function useEventPublisher() { return match } } + const replaceNoteId = (match: string) => { + try { + const hex = bech32ToHex(match); + const idx = ev.Tags.length; + ev.Tags.push(new Tag(["e", hex], idx)); + return `#[${idx}]` + } catch (error) { + return match + } + } const replaceHashtag = (match: string) => { const tag = match.slice(1); const idx = ev.Tags.length; ev.Tags.push(new Tag(["t", tag.toLowerCase()], idx)); return match; } - let content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub); - content = content.replace(HashtagRegex, replaceHashtag); + const content = msg.replace(/@npub[a-z0-9]+/g, replaceNpub) + .replace(/note[a-z0-9]+/g, replaceNoteId) + .replace(HashtagRegex, replaceHashtag); ev.Content = content; }