diff --git a/lib/discourse_chat/provider/slack/slack_message_formatter.rb b/lib/discourse_chat/provider/slack/slack_message_formatter.rb index 55e68a7..2277c65 100644 --- a/lib/discourse_chat/provider/slack/slack_message_formatter.rb +++ b/lib/discourse_chat/provider/slack/slack_message_formatter.rb @@ -41,6 +41,8 @@ module DiscourseChat::Provider::SlackProvider uri = URI(url) rescue nil return Discourse.current_hostname unless uri + return uri.to_s if uri.scheme == "mailto" + uri.host = Discourse.current_hostname if !uri.host uri.scheme = (SiteSetting.force_https ? 'https' : 'http') if !uri.scheme uri.to_s diff --git a/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb b/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb index 7cd773e..ddd8e9d 100644 --- a/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb +++ b/spec/lib/discourse_chat/provider/slack/slack_provider_spec.rb @@ -49,6 +49,18 @@ RSpec.describe DiscourseChat::Provider::SlackProvider do .to eq('') end end + + describe 'when post contains an email' do + it 'should return the right excerpt' do + post.update!(cooked: <<~COOKED + The address is my email + COOKED + ) + + expect(described_class.excerpt(post)) + .to eq('The address is ') + end + end end describe '.trigger_notifications' do