FIX: trim trailing slash from topic links

FIX: trim trailing slash from topic links

diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb
index a7be7fa..b8b72b7 100644
--- a/app/models/topic_link.rb
+++ b/app/models/topic_link.rb
@@ -205,7 +205,7 @@ SQL
       reflected_post = Post.find_by(topic_id: topic_id, post_number: post_number.to_i)
     end
 
-    url = url[0...TopicLink.max_url_length]
+    url = url[0...TopicLink.max_url_length]&.chomp("/")
     return nil if parsed && parsed.host && parsed.host.length > TopicLink.max_domain_length
 
     unless TopicLink.exists?(topic_id: post.topic_id, post_id: post.id, url: url)
diff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rb
index 8c7cea0..b45861c 100644
--- a/spec/models/topic_link_spec.rb
+++ b/spec/models/topic_link_spec.rb
@@ -41,7 +41,7 @@ describe TopicLink do
 
     it 'works' do
       expect(topic.topic_links.pluck(:url)).to contain_exactly(
-        "http://a.com/",
+        "http://a.com",
         "https://b.com/b",
         "//b.com/#{'a' * 500}"[0...TopicLink.max_url_length]
       )

GitHub
sha: 993f847a

Revert "FIX: trim trailing slash from topic links"