mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: Embedded topic was not found when URL contained query string
This commit is contained in:
parent
22f0b0096d
commit
5a56746610
@ -183,7 +183,7 @@ class TopicEmbed < ActiveRecord::Base
|
||||
|
||||
def self.topic_id_for_embed(embed_url)
|
||||
embed_url = normalize_url(embed_url).sub(/^https?\:\/\//, '')
|
||||
TopicEmbed.where("embed_url ~* '^https?://#{embed_url}$'").pluck(:topic_id).first
|
||||
TopicEmbed.where("embed_url ~* '^https?://#{Regexp.escape(embed_url)}$'").pluck(:topic_id).first
|
||||
end
|
||||
|
||||
def self.first_paragraph_from(html)
|
||||
|
@ -72,6 +72,11 @@ describe TopicEmbed do
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/24')).to eq(nil)
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post')).to eq(nil)
|
||||
end
|
||||
|
||||
it "finds the topic id when the embed_url contains a query string" do
|
||||
topic_embed = Fabricate(:topic_embed, embed_url: "http://example.com/post/248?key=foo")
|
||||
expect(TopicEmbed.topic_id_for_embed('http://example.com/post/248?key=foo')).to eq(topic_embed.topic_id)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.find_remote' do
|
||||
|
Loading…
Reference in New Issue
Block a user