Skip to content

Add support for mentioning channels by ID. e.g. <#C04A9JK5R3Z>#49

Merged
jsarafajr merged 2 commits intojsarafajr:masterfrom
nbarnett:master
Jun 19, 2025
Merged

Add support for mentioning channels by ID. e.g. <#C04A9JK5R3Z>#49
jsarafajr merged 2 commits intojsarafajr:masterfrom
nbarnett:master

Conversation

@nbarnett
Copy link
Contributor

Similar to user mentions, Slack supports mentioning channels via their ID. For example <#C04A9JK5R3Z> will be transformed to #general. This PR adds the # prefix to the existing @ prefix in the regex for checking user mentions, so that the angle brackets don't get escaped. Test included.

@codecov
Copy link

codecov bot commented Jun 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7aa6c0b) to head (0f1c1d0).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #49   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          109       109           
  Branches        18        18           
=========================================
  Hits           109       109           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jsarafajr jsarafajr requested a review from Copilot June 19, 2025 17:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the mention parsing logic to also support channel mentions by ID, in addition to the existing user mention support.

  • Updates regex patterns in src/slackify.js to include the '#' prefix.
  • Adds a new test case for channel mention in test/slackify-markdown.test.js.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/slackify.js Updated regex to handle both '@' and '#' prefixes
test/slackify-markdown.test.js Added test to verify channel mention handling
Comments suppressed due to low confidence (1)

src/slackify.js:14

  • The variable name 'isEndOfUserMention' is now used to check mentions that may include channels as well as users. Consider renaming it to a more inclusive name, such as 'isEndOfMention'.
      const isEndOfUserMention = Boolean(m.match(/<[@#][A-Z0-9]+$/));

@jsarafajr jsarafajr merged commit b1f8db8 into jsarafajr:master Jun 19, 2025
7 checks passed
@jsarafajr
Copy link
Owner

Thanks, will publish as new minor version today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants