mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
use nip27 replacer instead of janky regex
This commit is contained in:
parent
e4f24c3b26
commit
9175596d5f
1 changed files with 5 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { NostrMetadata, NSchema as n } from '@nostrify/nostrify';
|
||||
import { getEvent } from '@/queries.ts';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { nip19, nip27 } from 'nostr-tools';
|
||||
import { match } from 'path-to-regexp';
|
||||
|
||||
import { lookupAccount, lookupPubkey } from '@/utils/lookup.ts';
|
||||
|
|
@ -106,8 +106,10 @@ export async function getStatusInfo(id: string): Promise<StatusInfo> {
|
|||
const handle = await getHandle(event.pubkey);
|
||||
const res: StatusInfo = {
|
||||
title: `View @${handle}'s post on Ditto`,
|
||||
description: event.content
|
||||
.replace(/nostr:(npub1(?:[0-9]|[a-z]){58})/g, (_, key: string) => `@${key.slice(0, 8)}`),
|
||||
description: nip27.replaceAll(
|
||||
event.content,
|
||||
({ decoded, value }) => decoded.type === 'npub' ? value.slice(0, 8) : '',
|
||||
),
|
||||
};
|
||||
|
||||
const data: string[][] = event.tags
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue