fixes #3119
This commit is contained in:
@@ -52,7 +52,11 @@ class TwitterService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def extract_urls_for_card(attrs)
|
def extract_urls_for_card(attrs)
|
||||||
url = attrs.urls.map {|x| x.expanded_url}.reject {|x| x.host == "twitter.com"}.first
|
urls = attrs.urls.map {|x| x.expanded_url}
|
||||||
|
url = urls.reject {|x| x.host == "twitter.com"}.first
|
||||||
|
if url.nil?
|
||||||
|
url = urls.first
|
||||||
|
end
|
||||||
[extract_og_image_from_page(url)].compact
|
[extract_og_image_from_page(url)].compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ module Sources
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "A twitter summary card from twitter" do
|
||||||
|
setup do
|
||||||
|
@site = Sources::Site.new("https://twitter.com/masayasuf/status/870734961778630656/photo/1")
|
||||||
|
@site.get
|
||||||
|
end
|
||||||
|
|
||||||
|
should "get the image url" do
|
||||||
|
assert_equal("https://pbs.twimg.com/media/DBV40M2UIAAHYlt.jpg:large", @site.image_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "The source site for a restricted twitter" do
|
context "The source site for a restricted twitter" do
|
||||||
setup do
|
setup do
|
||||||
@site = Sources::Site.new("https://mobile.twitter.com/Strangestone/status/556440271961858051")
|
@site = Sources::Site.new("https://mobile.twitter.com/Strangestone/status/556440271961858051")
|
||||||
|
|||||||
Reference in New Issue
Block a user