Bug Description
The regex /(?<!<)@(\w+)/g in packages/adapter-slack/src/markdown.ts converts @word to <@word> for Slack mentions. The lookbehind only excludes < before @, so email addresses like user@example.com get rewritten to user<@example>.com. This also breaks <mailto:user@example.com> links.
|
private convertMentionsToSlack(text: string): string { |
|
return text.replace(/(?<!<)@(\w+)/g, "<@$1>"); |
|
} |
Steps to Reproduce
Post a message containing an email address through the Slack adapter:
await adapter.postChannelMessage('slack:C1234', 'Contact user@example.com for help');
Expected Behavior
Slack displays: Contact user@example.com for help with the email auto-linked.
Actual Behavior
Slack displays: Contact user@example.com for help with @example rendered as a broken user mention, because the text sent to Slack is Contact user<@example>.com for help.
This also affects mailto: links — mailto:user@example.com becomes <mailto:user<@example>.com>.
Code Sample
Chat SDK Version
4.26
Node.js Version
24
Platform Adapter
Slack
Operating System
macOS
Additional Context
Potential fix is to add \w to the lookbehind:
/(?<![<\w])@(\w+)/g
Bug Description
The regex /(?<!<)@(\w+)/g in
packages/adapter-slack/src/markdown.tsconverts@wordto<@word>for Slack mentions. The lookbehind only excludes < before @, so email addresses likeuser@example.comget rewritten touser<@example>.com. This also breaks<mailto:user@example.com>links.chat/packages/adapter-slack/src/markdown.ts
Lines 41 to 43 in 1c12d33
Steps to Reproduce
Post a message containing an email address through the Slack adapter:
await adapter.postChannelMessage('slack:C1234', 'Contact user@example.com for help');
Expected Behavior
Slack displays: Contact user@example.com for help with the email auto-linked.
Actual Behavior
Slack displays: Contact user@example.com for help with @example rendered as a broken user mention, because the text sent to Slack is Contact user<@example>.com for help.
This also affects mailto: links — mailto:user@example.com becomes <mailto:user<@example>.com>.
Code Sample
Chat SDK Version
4.26
Node.js Version
24
Platform Adapter
Slack
Operating System
macOS
Additional Context
Potential fix is to add \w to the lookbehind:
/(?<![<\w])@(\w+)/g