refactor channel

This commit is contained in:
Ren Amamiya
2023-06-17 12:28:46 +07:00
parent 0a6865431d
commit c9f7d942a0
21 changed files with 275 additions and 291 deletions

View File

@@ -4,8 +4,19 @@ import getUrls from "get-urls";
import { parseReferences } from "nostr-tools";
import reactStringReplace from "react-string-replace";
function isJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
export function parser(event: any) {
event.tags = destr(event.tags);
if (isJsonString(event.tags)) {
event["tags"] = destr(event.tags);
}
const references = parseReferences(event);
const urls = getUrls(event.content);