This commit is contained in:
Doug Hoyte
2023-09-10 17:00:05 -04:00
parent 5258d1f4c2
commit ce4160f0d4
2 changed files with 13 additions and 2 deletions

View File

@ -312,7 +312,7 @@ struct Event {
inline void preprocessEventContent(lmdb::txn &txn, Decompressor &decomp, const Event &ev, UserCache &userCache, std::string &content) {
static RE2 matcher(R"((?is)(.*?)(https?://\S+|#\[\d+\]|nostr:note1\w+))");
static RE2 matcher(R"((?is)(.*?)(https?://\S+|#\[\d+\]|nostr:(?:note|npub)1\w+))");
std::string output;
@ -338,6 +338,18 @@ inline void preprocessEventContent(lmdb::txn &txn, Decompressor &decomp, const E
std::string path = "/e/";
path += sv(match).substr(6);
appendLink(path, sv(match));
} else if (match.starts_with("nostr:npub1")) {
bool didTransform = false;
try {
const auto *u = userCache.getUser(txn, decomp, decodeBech32Simple(sv(match).substr(6)));
appendLink(std::string("/u/") + u->npubId, std::string("@") + u->username);
didTransform = true;
} catch(std::exception &e) {
//LW << "tag parse error: " << e.what();
}
if (!didTransform) output += sv(match);
} else if (match.starts_with("#[")) {
bool didTransform = false;
auto offset = std::stoull(std::string(sv(match)).substr(2, match.size() - 3));

View File

@ -205,7 +205,6 @@ table.vert {
.content {
padding-left: 25px;
margin-top: -10px;
}
}