(text: string)
| 110 | * This is a known limitation of simple regex-based parsing. |
| 111 | */ |
| 112 | export function markdownToSlackLinks(text: string): string { |
| 113 | // Match markdown links: [text](url) |
| 114 | // Capture group 1: link text, Capture group 2: URL |
| 115 | return text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, linkText, url) => { |
| 116 | // Escape pipe characters in link text to prevent breaking Slack mrkdwn |
| 117 | // lgtm[js/incomplete-sanitization] -- only pipe needs escaping for Slack mrkdwn <url|text> syntax |
| 118 | const escapedText = linkText.replace(/\|/g, '\\|'); |
| 119 | return `<${url}|${escapedText}>`; |
| 120 | }); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Validate output before sending to Slack |
no outgoing calls
no test coverage detected