Skip to content

Commit

Permalink
Merge pull request slackapi#125 from paulhammond/mailto-fix
Browse files Browse the repository at this point in the history
Strip mailto: from mailto: links
  • Loading branch information
paulhammond committed Dec 17, 2014
2 parents f3a288b + d9c8d1c commit 64d7c57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/slack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class SlackBot extends Adapter
(?:\|([^>]+))? # label
> # closing angle bracket
///g, (m, link, label) =>
link = link.replace /^mailto:/, ''
if label
"#{label} #{link}"
else
Expand Down
10 changes: 7 additions & 3 deletions test/slack.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ describe 'Removing message formatting', ->
foo = slackbot.removeFormatting 'foo <https://www.example.com> bar'
foo.should.equal 'foo https://www.example.com bar'

it 'Should remove formatting around <mailto> links', ->
foo = slackbot.removeFormatting 'foo <mailto:[email protected]> bar'
foo.should.equal 'foo mailto:[email protected] bar'
it 'Should remove formatting around <skype> links', ->
foo = slackbot.removeFormatting 'foo <skype:echo123?call> bar'
foo.should.equal 'foo skype:echo123?call bar'

it 'Should remove formatting around <https> links with a label', ->
foo = slackbot.removeFormatting 'foo <https://www.example.com|label> bar'
foo.should.equal 'foo label https://www.example.com bar'

it 'Should remove formatting around <mailto> links', ->
foo = slackbot.removeFormatting 'foo <mailto:[email protected]> bar'
foo.should.equal 'foo [email protected] bar'

it 'Should change multiple links at once', ->
foo = slackbot.removeFormatting 'foo <@U123|label> bar <#C123> <!channel> <https://www.example.com|label>'
foo.should.equal 'foo label bar #general @channel label https://www.example.com'
Expand Down

0 comments on commit 64d7c57

Please sign in to comment.