From d1597683f378fd151483d894b1e06cf5be9d6eb7 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 3 Jan 2019 17:29:22 +0530 Subject: [PATCH] Revert "FIX: trim trailing slash from topic links" This reverts commit 993f847a2c6f40fbbb9c2bd2ca4d483dbb46b5bf. There is an edge case where the link click redirect fails when the URL has trailing slash. Need to figure out a better fix for this. --- app/models/topic_link.rb | 2 +- spec/models/topic_link_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/topic_link.rb b/app/models/topic_link.rb index b8b72b71097..a7be7fa00c3 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]&.chomp("/") + url = url[0...TopicLink.max_url_length] 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 b45861ceb16..8c7cea0a4a4 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] )