From a9a93b15ec49fcf16bbcc82e12436074745d2b69 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 25 Feb 2021 13:31:38 +0200 Subject: [PATCH] FIX: Strip whitespace from URL before validating (#12174) --- lib/topic_retriever.rb | 2 +- spec/components/topic_retriever_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/topic_retriever.rb b/lib/topic_retriever.rb index 8fae22a368d..a865143ce66 100644 --- a/lib/topic_retriever.rb +++ b/lib/topic_retriever.rb @@ -15,7 +15,7 @@ class TopicRetriever private def invalid_url? - !EmbeddableHost.url_allowed?(@embed_url) + !EmbeddableHost.url_allowed?(@embed_url.strip) end def retrieved_recently? diff --git a/spec/components/topic_retriever_spec.rb b/spec/components/topic_retriever_spec.rb index 6fd602c67ef..3bc2ec81b72 100644 --- a/spec/components/topic_retriever_spec.rb +++ b/spec/components/topic_retriever_spec.rb @@ -63,6 +63,11 @@ describe TopicRetriever do end end end + + it "works with URLs with whitespaces" do + expect { TopicRetriever.new(" https://example.com ").retrieve } + .not_to raise_error + end end end