Skip to content

A platform for community discussion. Free, open, simple.

FIX: Don't raise an exception if a topic cannot be retrieved (#9906)

Roman Rizzia41476800b37
diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb
index d8aef830806..7529e98353e 100644
--- a/app/models/topic_embed.rb
+++ b/app/models/topic_embed.rb
@@ -116,7 +116,7 @@ class TopicEmbed < ActiveRecord::Base
)
url = fd.resolve
- raise URI::InvalidURIError if url.blank?
+ return if url.blank?
opts = {
tags: %w[div p code pre h1 h2 h3 b em i strong a img ul li ol blockquote],
diff --git a/spec/models/topic_embed_spec.rb b/spec/models/topic_embed_spec.rb
index cfdddd389b0..bc061ddcbe4 100644
--- a/spec/models/topic_embed_spec.rb
+++ b/spec/models/topic_embed_spec.rb
@@ -311,9 +311,10 @@ describe TopicEmbed do
end
context "non-http URL" do
- let(:url) { '/test.txt' }
it "throws an error" do
- expect { TopicEmbed.find_remote(url) }.to raise_error(URI::InvalidURIError)
+ url = '/test.txt'
+
+ expect(TopicEmbed.find_remote(url)).to be_nil
end
end