lib/onebox/engine/twitter_status_onebox.rb in onebox-1.7.5 vs lib/onebox/engine/twitter_status_onebox.rb in onebox-1.7.6
- old
+ new
@@ -3,17 +3,17 @@
class TwitterStatusOnebox
include Engine
include LayoutSupport
include HTML
- matches_regexp Regexp.new("^https?://(?:www\\.)?(?:(?:\\w)+\\.)?(twitter)\\.com(?:/)?(?:.)*/status(es)?/")
+ matches_regexp /^https?:\/\/(mobile\.|www\.)?twitter\.com\/.+?\/status(es)?\/\d+$/
always_https
private
def get_twitter_data
- response = Onebox::Helpers.fetch_response(url)
- html = Nokogiri::HTML(response.body)
+ response = Onebox::Helpers.fetch_response(url) rescue nil
+ html = Nokogiri::HTML(response)
twitter_data = {}
html.css('meta').each do |m|
if m.attribute('property') && m.attribute('property').to_s.match(/^og:/i)
m_content = m.attribute('content').to_s.strip
m_property = m.attribute('property').to_s.gsub('og:', '')