@@ -337,7 +337,7 @@ struct Event {
337337 }
338338
339339 void preprocessEventContent (lmdb::txn &txn, Decompressor &decomp, UserCache &userCache, std::string &content, bool withLinks = true ) const {
340- static RE2 matcher (R"( (?is)(.*?)(https?://\S+|#\[\d+\]|nostr:(?:note|npub)1\w+))" );
340+ static RE2 matcher (R"( (?is)(.*?)(https?://\S+|#\[\d+\]|nostr:(?:note|npub|nevent|nprofile )1\w+))" );
341341
342342 std::string output;
343343
@@ -367,16 +367,38 @@ struct Event {
367367 std::string path = " /e/" ;
368368 path += sv (match).substr (6 );
369369 appendLink (path, sv (match));
370+ } else if (match.starts_with (" nostr:nevent1" )) {
371+ bool didTransform = false ;
372+
373+ try {
374+ auto id = decodeBech32GetSpecial (sv (match).substr (6 ));
375+ std::string path = " /e/" ;
376+ path += encodeBech32Simple (" note" , id);
377+
378+ appendLink (path, sv (match));
379+ didTransform = true ;
380+ } catch (...) {}
381+
382+ if (!didTransform) output += sv (match);
370383 } else if (match.starts_with (" nostr:npub1" )) {
371384 bool didTransform = false ;
372385
373386 try {
374387 const auto *u = userCache.getUser (txn, decomp, decodeBech32Simple (sv (match).substr (6 )));
375388 appendLink (std::string (" /u/" ) + u->npubId , std::string (" @" ) + u->username );
376389 didTransform = true ;
377- } catch (std::exception &e) {
378- // LW << "tag parse error: " << e.what();
379- }
390+ } catch (...) {}
391+
392+ if (!didTransform) output += sv (match);
393+ } else if (match.starts_with (" nostr:nprofile" )) {
394+ bool didTransform = false ;
395+
396+ try {
397+ auto pubkey = decodeBech32GetSpecial (sv (match).substr (6 ));
398+ const auto *u = userCache.getUser (txn, decomp, pubkey);
399+ appendLink (std::string (" /u/" ) + u->npubId , std::string (" @" ) + u->username );
400+ didTransform = true ;
401+ } catch (...) {}
380402
381403 if (!didTransform) output += sv (match);
382404 } else if (match.starts_with (" #[" )) {
0 commit comments