MCPcopy Create free account
hub / github.com/SuperteamDAO/earn / parseComment

Function parseComment

src/features/comments/components/CommentParser.tsx:34–49  ·  view source on GitHub ↗
(comment: string)

Source from the content-addressed store, hash-verified

32 const CHARACTER_LIMIT = 200;
33
34 function parseComment(comment: string) {
35 const tokens = comment.split(/(\s+|@\w+[\w-]*|[^\s@]+)/g).filter(Boolean);
36
37 return tokens.map((token) => {
38 const mentionMatch = token.match(/^@(\w+[\w-]*)/);
39 if (mentionMatch && validUsernames.includes(mentionMatch[1] || '')) {
40 return { type: 'mention', value: mentionMatch[0] };
41 }
42
43 if (isLink(token)) {
44 return { type: 'link', value: token };
45 }
46
47 return { type: 'text', value: token };
48 });
49 }
50
51 function renderParsedComment(parsedComment: ReturnType<typeof parseComment>) {
52 return parsedComment.map((part, index) => {

Callers 1

CommentParserFunction · 0.85

Calls 1

isLinkFunction · 0.90

Tested by

no test coverage detected