FIX: topic link extraction shouldn't fail when the parsed URL has no path
This commit is contained in:
parent
6c829c24d7
commit
1cae875146
|
@ -161,7 +161,7 @@ SQL
|
||||||
added_urls << url
|
added_urls << url
|
||||||
|
|
||||||
unless TopicLink.exists?(topic_id: post.topic_id, post_id: post.id, url: url)
|
unless TopicLink.exists?(topic_id: post.topic_id, post_id: post.id, url: url)
|
||||||
file_extension = File.extname(parsed.path)[1..10].downcase unless File.extname(parsed.path).empty?
|
file_extension = File.extname(parsed.path)[1..10].downcase unless parsed.path.nil? || File.extname(parsed.path).empty?
|
||||||
begin
|
begin
|
||||||
TopicLink.create!(post_id: post.id,
|
TopicLink.create!(post_id: post.id,
|
||||||
user_id: post.user_id,
|
user_id: post.user_id,
|
||||||
|
|
|
@ -230,7 +230,6 @@ http://b.com/#{'a' * 500}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'internal link from pm' do
|
describe 'internal link from pm' do
|
||||||
|
@ -382,6 +381,11 @@ http://b.com/#{'a' * 500}
|
||||||
expect(result).to eq({})
|
expect(result).to eq({})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "works with invalid link target" do
|
||||||
|
post = Fabricate(:post, raw: '<a href="http:geturl">http:geturl</a>', user: user, topic: topic, cook_method: Post.cook_methods[:raw_html])
|
||||||
|
expect { TopicLink.extract_from(post) }.to_not raise_error
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue