Skip to content

Commit

Permalink
Merge pull request #7 from ry-itto/fix/#5/support_multiple_slack_user…
Browse files Browse the repository at this point in the history
…names

Support multiple slackUsernames
  • Loading branch information
Ryoya Ito authored Feb 26, 2021
2 parents e676eee + 084a2f1 commit 03c72ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

13 changes: 13 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>')
})
})
})
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 03c72ea

Please sign in to comment.