mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FIX: Improve top links section from user summary (#15675)
* Do not extract links for hotlinked images * Include only links that have been clicked at least once in user summary
This commit is contained in:
@ -836,6 +836,20 @@ describe PrettyText do
|
||||
expect(extract_urls("<aside class=\"quote\" data-topic=\"321\">aside</aside>")).to eq(["/t/321"])
|
||||
end
|
||||
|
||||
it "does not extract links from hotlinked images" do
|
||||
html = <<~HTML
|
||||
<p>
|
||||
<a href="https://example.com">example</a>
|
||||
|
||||
<a href="https://images.pexels.com/photos/1525041/pexels-photo-1525041.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2" target="_blank" rel="noopener" class="onebox">
|
||||
<img src="https://images.pexels.com/photos/1525041/pexels-photo-1525041.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2" width="690" height="459">
|
||||
</a>
|
||||
</p>
|
||||
HTML
|
||||
|
||||
expect(extract_urls(html)).to eq(["https://example.com"])
|
||||
end
|
||||
|
||||
it "should lazyYT videos" do
|
||||
expect(extract_urls("<div class=\"lazyYT\" data-youtube-id=\"yXEuEUQIP3Q\" data-youtube-title=\"Mister Rogers defending PBS to the US Senate\" data-width=\"480\" data-height=\"270\" data-parameters=\"feature=oembed&wmode=opaque\"></div>")).to eq(["https://www.youtube.com/watch?v=yXEuEUQIP3Q"])
|
||||
end
|
||||
|
Reference in New Issue
Block a user