FIX: Handle `mailto` links in slack messages
This commit is contained in:
parent
bf1939f08d
commit
b7dff35722
|
@ -41,6 +41,8 @@ module DiscourseChat::Provider::SlackProvider
|
||||||
uri = URI(url) rescue nil
|
uri = URI(url) rescue nil
|
||||||
|
|
||||||
return Discourse.current_hostname unless uri
|
return Discourse.current_hostname unless uri
|
||||||
|
return uri.to_s if uri.scheme == "mailto"
|
||||||
|
|
||||||
uri.host = Discourse.current_hostname if !uri.host
|
uri.host = Discourse.current_hostname if !uri.host
|
||||||
uri.scheme = (SiteSetting.force_https ? 'https' : 'http') if !uri.scheme
|
uri.scheme = (SiteSetting.force_https ? 'https' : 'http') if !uri.scheme
|
||||||
uri.to_s
|
uri.to_s
|
||||||
|
|
|
@ -49,6 +49,18 @@ RSpec.describe DiscourseChat::Provider::SlackProvider do
|
||||||
.to eq('<http://somesource.com|meta.discourse.org>')
|
.to eq('<http://somesource.com|meta.discourse.org>')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when post contains an email' do
|
||||||
|
it 'should return the right excerpt' do
|
||||||
|
post.update!(cooked: <<~COOKED
|
||||||
|
The address is <a href=\"mailto:someone@domain.com\">my email</a>
|
||||||
|
COOKED
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(described_class.excerpt(post))
|
||||||
|
.to eq('The address is <mailto:someone@domain.com|my email>')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.trigger_notifications' do
|
describe '.trigger_notifications' do
|
||||||
|
|
Loading…
Reference in New Issue