diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 241e548..4b2d04a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,5 +21,5 @@ jobs: SLACK_USERNAME: 'Capicapi' SLACK_GITHUB_USER_PAIRS: ${{ secrets.SLACK_USER }} TITLE: ':tada: Success :tada:' - BODY: 'ry-itto ry-itto ry-itto' + BODY: 'ry-itto github octocat' diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 95fa8f3..d0c5d9b 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -51,5 +51,18 @@ describe('utils test', () => { ) expect(result).toBe('`@ry-itto`') }) + + it('multiple slackUsernames', () => { + const slackUsernames = ` + ry-itto,ito ryoya + github,octocat + ` + const body = 'ry-itto and github' + const result = replaceGitHubUsernameWithSlackUsername( + body, + slackUsernames + ) + expect(result).toBe('<@ito ryoya> and <@octocat>') + }) }) }) diff --git a/src/utils.ts b/src/utils.ts index cdf0087..e9d5fae 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -106,7 +106,7 @@ export const replaceGitHubUsernameWithSlackUsername = ( if (!value) { return result } - result[key] = value + result[key.trim()] = value.trim() return result }, {}) ?? {} for (const [key, value] of Object.entries(githubToSlack)) {