(comment: string)
| 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) => { |
no test coverage detected