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

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

diff --git a/app/models/topic_embed.rb b/app/models/topic_embed.rb
index d8aef83..7529e98 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 cfdddd3..bc061dd 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
 

GitHub sha: a4147680

1 Like

This commit appears in #9906 which was approved by eviltrout. It was merged by romanrizzi.