mirror of
https://github.com/discourse/discourse.git
synced 2025-03-23 07:55:43 +08:00
Apply the same url normalisation to embed_urls inserted in the PostCreator (#30641)
This commit is contained in:
parent
773857848b
commit
427ea5301b
@ -405,7 +405,7 @@ class PostCreator
|
||||
TopicEmbed.new(
|
||||
topic_id: @post.topic_id,
|
||||
post_id: @post.id,
|
||||
embed_url: @opts[:embed_url],
|
||||
embed_url: TopicEmbed.normalize_url(@opts[:embed_url]),
|
||||
content_sha1: @opts[:embed_content_sha1],
|
||||
)
|
||||
rollback_from_errors!(embed) unless embed.save
|
||||
|
@ -1512,6 +1512,20 @@ RSpec.describe PostCreator do
|
||||
expect(post.topic).not_to be_visible
|
||||
end
|
||||
end
|
||||
|
||||
it "normalizes the embed url" do
|
||||
embed_url = "http://eviltrout.com/stupid-url/"
|
||||
creator =
|
||||
PostCreator.new(
|
||||
user,
|
||||
embed_url: embed_url,
|
||||
title: "Reviews of Science Ovens",
|
||||
raw: "Did you know that you can use microwaves to cook your dinner? Science!",
|
||||
)
|
||||
creator.create
|
||||
expect(creator.errors).to be_blank
|
||||
expect(TopicEmbed.where(embed_url: "http://eviltrout.com/stupid-url").exists?).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
describe "read credit for creator" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user