diff --git a/src/app/shared/content/content.html b/src/app/shared/content/content.html index 90dd16c..3c19686 100644 --- a/src/app/shared/content/content.html +++ b/src/app/shared/content/content.html @@ -15,11 +15,17 @@ {{ token }} + + @{{ getDisplayName(token.word) }} + @{{ getDisplayName(token.word) }} + {{ token.word }} + {{ token.word }} + @{{ getDisplayName(token.word) }} {{ token.word }}
- + 1 @@ -47,6 +53,12 @@
+ + @{{ getDisplayName(token.word) }} + @{{ getDisplayName(token.word) }} + {{ token.word }} + {{ token.word }} + @{{ getDisplayName(token.word) }} {{ token.word }} {{ token.word }} diff --git a/src/app/shared/content/content.ts b/src/app/shared/content/content.ts index 3c58cab..f4331e2 100644 --- a/src/app/shared/content/content.ts +++ b/src/app/shared/content/content.ts @@ -9,6 +9,7 @@ import { ProfileService } from 'src/app/services/profile'; import { Utilities } from 'src/app/services/utilities'; import { NostrEventDocument, NostrProfile, NostrProfileDocument, TokenKeyword } from '../../services/interfaces'; import { ProfileImageDialog } from '../profile-image-dialog/profile-image-dialog'; +import { nip19 } from 'nostr-tools'; interface MediaItem { url: SafeResourceUrl; @@ -132,6 +133,7 @@ export class ContentComponent { } getDisplayName(pubkey: string) { + pubkey = this.utilities.ensureHexIdentifier(pubkey); const profile = this.profileService.getCachedProfile(pubkey); if (!profile) { @@ -281,6 +283,21 @@ export class ContentComponent { } i = res.push(keyword); + } else if (token.startsWith('nostr:')) { + const decoded = nip19.decode(token.substring(6)); + const val = decoded.data as any; + + if (decoded.type === 'nprofile') { + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val.pubkey, token: decoded.type }); + } else if (decoded.type === 'npub') { + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val, token: decoded.type }); + } else if (decoded.type === 'note') { + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val, token: decoded.type }); + } else if (decoded.type === 'nevent') { + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: val.id, token: decoded.type }); + } else { + i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token.substring(6), token: decoded.type }); + } } else if (token.startsWith('http://') || token.startsWith('https://')) { if (this.isImage(token)) { i = res.push({ safeWord: this.utilities.sanitizeUrlAndBypass(token), word: token, token: 'image' });