This commit is contained in:
r888888888
2017-06-14 16:30:19 -07:00
parent b2245349b3
commit f27d065e1f
2 changed files with 16 additions and 1 deletions

View File

@@ -52,7 +52,11 @@ class TwitterService
end
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
end

View File

@@ -35,6 +35,17 @@ module Sources
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
setup do
@site = Sources::Site.new("https://mobile.twitter.com/Strangestone/status/556440271961858051")