onebox 1.5.21 → 1.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onebox/engine.rb +18 -2
  3. data/lib/onebox/engine/amazon_onebox.rb +12 -6
  4. data/lib/onebox/engine/audio_onebox.rb +4 -0
  5. data/lib/onebox/engine/github_blob_onebox.rb +1 -1
  6. data/lib/onebox/engine/github_commit_onebox.rb +4 -2
  7. data/lib/onebox/engine/github_gist_onebox.rb +1 -0
  8. data/lib/onebox/engine/github_issue_onebox.rb +5 -3
  9. data/lib/onebox/engine/github_pullrequest_onebox.rb +4 -2
  10. data/lib/onebox/engine/google_calendar_onebox.rb +1 -0
  11. data/lib/onebox/engine/google_docs_onebox.rb +1 -0
  12. data/lib/onebox/engine/google_maps_onebox.rb +5 -3
  13. data/lib/onebox/engine/google_play_app_onebox.rb +2 -1
  14. data/lib/onebox/engine/image_onebox.rb +4 -0
  15. data/lib/onebox/engine/pubmed_onebox.rb +1 -1
  16. data/lib/onebox/engine/soundcloud_onebox.rb +2 -1
  17. data/lib/onebox/engine/stack_exchange_onebox.rb +6 -2
  18. data/lib/onebox/engine/standard_embed.rb +6 -1
  19. data/lib/onebox/engine/twitter_status_onebox.rb +2 -1
  20. data/lib/onebox/engine/video_onebox.rb +4 -0
  21. data/lib/onebox/engine/whitelisted_generic_onebox.rb +6 -7
  22. data/lib/onebox/engine/wikipedia_onebox.rb +1 -0
  23. data/lib/onebox/engine/youtube_onebox.rb +2 -6
  24. data/lib/onebox/version.rb +1 -1
  25. data/spec/fixtures/amazon.response +2845 -1268
  26. data/spec/lib/onebox/engine/amazon_onebox_spec.rb +10 -2
  27. data/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb +1 -1
  28. data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +3 -3
  29. data/spec/lib/onebox/engine/wikipedia_onebox_spec.rb +1 -0
  30. data/spec/lib/onebox/engine/youtube_onebox_spec.rb +4 -2
  31. data/spec/lib/onebox/engine_spec.rb +22 -2
  32. data/spec/lib/onebox/preview_spec.rb +1 -1
  33. data/templates/amazon.mustache +1 -1
  34. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d81ab9ca72a2dea627e57a27c47f38afce6cfaca
4
- data.tar.gz: 01a0b589ea13c180bf59d83acd4a41b96f156d75
3
+ metadata.gz: 2fb92353f1527a271605471d0115a60931073832
4
+ data.tar.gz: c97622b3d51890dd888e15f0be87493e910901a7
5
5
  SHA512:
6
- metadata.gz: e6cfa6120bdbb68a11343f8858e528767d29e94e6fcec54e1c6b60c9ed1e513de6f311cdb5d461f6b0ed090ccd4ec4279e56e0c0ac57ad0a3d5f9448f9563298
7
- data.tar.gz: 5cddf24c71ff367a226c41cd1b399c4ba288317879ab1537c0b1209ee3179a5a6681c7d676984f8ce464f0d973386858b24f9c3f3116c7c0e300dfe2643c882a
6
+ metadata.gz: 3af69983a71d88760ffeb61123c414cbc6ba999bff37e4e326a482637d248b3869bd93e4ae49c2d6c601fb2c79da4116e12df40993c7509c539a481a9d2751e6
7
+ data.tar.gz: 2468de3c42c9dcf6fd8532e9790fa4432a6d8e185238e7e73011c19f008de281780448b76db420744c5452047c5d3590ec7e99b1901d159e64ed95c566d62704
data/lib/onebox/engine.rb CHANGED
@@ -10,7 +10,7 @@ module Onebox
10
10
  end.map(&method(:const_get))
11
11
  end
12
12
 
13
- attr_reader :url
13
+ attr_reader :url, :uri
14
14
  attr_reader :cache
15
15
  attr_reader :timeout
16
16
 
@@ -37,6 +37,11 @@ module Onebox
37
37
  self.options = Onebox.options[class_name] || {} #Set the engine options extracted from global options.
38
38
 
39
39
  @url = link
40
+ @uri = URI(link)
41
+ if always_https?
42
+ @uri.scheme = 'https'
43
+ @url = @uri.to_s
44
+ end
40
45
  @cache = cache || Onebox.options.cache
41
46
  @timeout = timeout || Onebox.options.timeout
42
47
  end
@@ -81,7 +86,7 @@ module Onebox
81
86
  end
82
87
 
83
88
  def link
84
- @url.gsub(/['\"<>]/, {
89
+ @url.gsub(/['\"&<>]/, {
85
90
  "'" => '&#39;',
86
91
  '&' => '&amp;',
87
92
  '"' => '&quot;',
@@ -90,6 +95,10 @@ module Onebox
90
95
  })
91
96
  end
92
97
 
98
+ def always_https?
99
+ self.class.always_https?
100
+ end
101
+
93
102
  module ClassMethods
94
103
  def ===(other)
95
104
  if other.kind_of?(URI)
@@ -112,6 +121,13 @@ module Onebox
112
121
  name.split("::").last.downcase.gsub(/onebox/, "")
113
122
  end
114
123
 
124
+ def always_https
125
+ @https = true
126
+ end
127
+
128
+ def always_https?
129
+ @https
130
+ end
115
131
  end
116
132
  end
117
133
  end
@@ -1,3 +1,5 @@
1
+ require 'json'
2
+
1
3
  module Onebox
2
4
  module Engine
3
5
  class AmazonOnebox
@@ -6,7 +8,7 @@ module Onebox
6
8
  include HTML
7
9
 
8
10
 
9
- matches_regexp(/^http:\/\/(?:www)\.amazon\.(?<tld>com|ca|de|it|es|fr|co\.jp|co\.uk|cn|in|com\.br)\//)
11
+ matches_regexp(/^https?:\/\/(?:www)\.amazon\.(?<tld>com|ca|de|it|es|fr|co\.jp|co\.uk|cn|in|com\.br)\//)
10
12
 
11
13
  def url
12
14
  return "http://www.amazon.#{tld}/gp/aw/d/" + URI::encode(match[:id]) if match && match[:id]
@@ -30,7 +32,11 @@ module Onebox
30
32
  def image
31
33
  case
32
34
  when raw.css("#main-image").any?
33
- raw.css("#main-image").first["src"]
35
+ ::JSON.parse(
36
+ raw.css("#main-image").first
37
+ .attributes["data-a-dynamic-image"]
38
+ .value
39
+ ).keys.first
34
40
  when raw.css("#landingImage").any?
35
41
  raw.css("#landingImage").first["src"]
36
42
  end
@@ -38,15 +44,15 @@ module Onebox
38
44
 
39
45
  def data
40
46
  result = { link: link,
41
- title: raw.css("h1").inner_text,
47
+ title: raw.css("title").inner_text,
42
48
  image: image,
43
- price: raw.css(".priceLarge").inner_text }
49
+ price: raw.css("#priceblock_ourprice").inner_text }
44
50
 
45
51
  result[:by_info] = raw.at("#by-line")
46
52
  result[:by_info] = Onebox::Helpers.clean(result[:by_info].inner_html) if result[:by_info]
47
53
 
48
- summary = raw.at("#about-item span")
49
- result[:description] = summary.inner_html if summary
54
+ summary = raw.at("#productDescription")
55
+ result[:description] = summary.inner_text if summary
50
56
  result
51
57
  end
52
58
  end
@@ -5,6 +5,10 @@ module Onebox
5
5
 
6
6
  matches_regexp /^(https?:)?\/\/.*\.(mp3|ogg|wav)(\?.*)?$/
7
7
 
8
+ def always_https?
9
+ WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
10
+ end
11
+
8
12
  def to_html
9
13
  "<audio controls><source src='#{@url}'><a href='#{@url}'>#{@url}</a></audio>"
10
14
  end
@@ -18,7 +18,7 @@ module Onebox
18
18
  }
19
19
 
20
20
  matches_regexp(/^https?:\/\/(www\.)?github\.com.*\/blob\//)
21
-
21
+ always_https
22
22
 
23
23
 
24
24
  def initialize(link, cache = nil, timeout = nil)
@@ -5,7 +5,8 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include JSON
7
7
 
8
- matches_regexp Regexp.new("^http(?:s)?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
8
+ matches_regexp Regexp.new("^https?://(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:/)?(?:.)*/commit/")
9
+ always_https
9
10
 
10
11
  def url
11
12
  "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/commits/#{match[:sha]}"
@@ -26,8 +27,9 @@ module Onebox
26
27
  result['message'] = result['commit']['message'].split("\n", 2).last.strip
27
28
  end
28
29
 
30
+ ulink = URI(link)
29
31
  result['commit_date'] = Time.parse(result['commit']['author']['date']).strftime("%I:%M%p - %d %b %y")
30
- result['repository_path'] = "#{URI(link).host}/#{URI(link).path.split('/')[1]}/#{URI(link).path.split('/')[2]}"
32
+ result['repository_path'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
31
33
  result['repository_url'] = "https://#{result['repository_path']}"
32
34
  result
33
35
  end
@@ -8,6 +8,7 @@ module Onebox
8
8
  MAX_FILES = 3
9
9
 
10
10
  matches_regexp Regexp.new("^http(?:s)?://gist\\.(?:(?:\\w)+\\.)?(github)\\.com(?:/)?")
11
+ always_https
11
12
 
12
13
  def url
13
14
  "https://api.github.com/gists/#{match[:sha]}"
@@ -5,7 +5,8 @@ module Onebox
5
5
  include Engine
6
6
  include LayoutSupport
7
7
  include JSON
8
- matches_regexp Regexp.new("^http(?:s)?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/issues\/([[:digit:]]+)")
8
+ matches_regexp Regexp.new("^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/issues\/([[:digit:]]+)")
9
+ always_https
9
10
 
10
11
  def url
11
12
  m = match
@@ -29,6 +30,7 @@ module Onebox
29
30
  short_content = content_words[0..max_words].join(" ")
30
31
  short_content << "..." if content_words.length > max_words
31
32
 
33
+ ulink = URI(link)
32
34
  status_color = {"open"=>"#6cc644","closed"=>"#bd2c00","merged"=>"#6e5494"}
33
35
  result = { link: @url,
34
36
  title: "Issue: " + @raw["title"],
@@ -39,8 +41,8 @@ module Onebox
39
41
  closed_at: (@raw['closed_at'].nil? ? "" : @raw['closed_at'].split("T")[0]),
40
42
  closed_by: @raw['closed_by'],
41
43
  avatar: "https://avatars1.githubusercontent.com/u/#{@raw['user']['id']}?v=2&s=96",
42
- repository_path: "#{URI(link).host}/#{URI(link).path.split('/')[1]}/#{URI(link).path.split('/')[2]}",
43
- repository_url: "https://#{URI(link).host}/#{URI(link).path.split('/')[1]}/#{URI(link).path.split('/')[2]}",
44
+ repository_path: "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}",
45
+ repository_url: "https://#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}",
44
46
  }
45
47
  end
46
48
  end
@@ -5,7 +5,8 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include JSON
7
7
 
8
- matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(github)\\.com(?:/)?(?:.)*/pull/")
8
+ matches_regexp Regexp.new("^https?://(?:www\\.)?(?:(?:\\w)+\\.)?(github)\\.com(?:/)?(?:.)*/pull/")
9
+ always_https
9
10
 
10
11
  def url
11
12
  "https://api.github.com/repos/#{match[:owner]}/#{match[:repository]}/pulls/#{match[:number]}"
@@ -21,7 +22,8 @@ module Onebox
21
22
  result = raw.clone
22
23
  result['link'] = link
23
24
  result['created_at'] = Time.parse(result['created_at']).strftime("%I:%M%p - %d %b %y")
24
- result['repository_path'] = "#{URI(link).host}/#{URI(link).path.split('/')[1]}/#{URI(link).path.split('/')[2]}"
25
+ ulink = URI(link)
26
+ result['repository_path'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
25
27
  result['repository_url'] = "https://#{result['repository_path']}"
26
28
  result
27
29
  end
@@ -4,6 +4,7 @@ module Onebox
4
4
  include Engine
5
5
 
6
6
  matches_regexp /^(https?:)?\/\/(www\.google\.[\w.]{2,}|goo\.gl)\/calendar\/.+$/
7
+ always_https
7
8
 
8
9
  def to_html
9
10
  url = @url.split('&').first
@@ -8,6 +8,7 @@ module Onebox
8
8
  end
9
9
 
10
10
  matches_regexp /^(https?:)?\/\/(docs\.google\.com)\/(?<endpoint>(#{supported_endpoints.join('|')}))\/d\/((?<key>[\w-]*)).+$/
11
+ always_https
11
12
 
12
13
  def to_html
13
14
  if document?
@@ -19,6 +19,8 @@ module Onebox
19
19
  end
20
20
  end
21
21
 
22
+ always_https
23
+
22
24
  # Matches shortened Google Maps URLs
23
25
  matches_regexp :short, %r"^(https?:)?//goo\.gl/maps/"
24
26
 
@@ -95,7 +97,7 @@ module Onebox
95
97
  url += "&q=#{$1}" if match = @url.match(/\/place\/([^\/\?]+)/)
96
98
  url += "&cid=#{($1 + $2).to_i(16)}" if @url.match(/!3m1!1s0x(\h{16}):0x(\h{16})/)
97
99
  @url = url
98
- @placeholder = "http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&center=#{location}&zoom=#{zoom}&size=690x400&sensor=false"
100
+ @placeholder = "https://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&center=#{location}&zoom=#{zoom}&size=690x400&sensor=false"
99
101
 
100
102
  when :custom
101
103
  url = @url.dup
@@ -113,7 +115,7 @@ module Onebox
113
115
  fov = (match[:zoom].to_f / 100.0).round(4).to_s
114
116
  zoom = match[:zoom].to_f.round
115
117
  @url = "https://www.google.com/maps/embed?pb=!3m2!2sen!4v0!6m8!1m7!1s#{panoid}!2m2!1d#{lon}!2d#{lat}!3f#{heading}!4f#{pitch}!5f#{fov}"
116
- @placeholder = "http://maps.googleapis.com/maps/api/streetview?size=690x400&location=#{lon},#{lat}&pano=#{panoid}&fov=#{zoom}&heading=#{heading}&pitch=#{pitch}&sensor=false"
118
+ @placeholder = "https://maps.googleapis.com/maps/api/streetview?size=690x400&location=#{lon},#{lat}&pano=#{panoid}&fov=#{zoom}&heading=#{heading}&pitch=#{pitch}&sensor=false"
117
119
 
118
120
  when :canonical
119
121
  uri = URI(@url)
@@ -136,7 +138,7 @@ module Onebox
136
138
  zoom = query["z"]
137
139
  end
138
140
  @url = @url.sub('output=classic', 'output=embed')
139
- @placeholder = "http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&size=690x400&sensor=false&center=#{location}&zoom=#{zoom}"
141
+ @placeholder = "https://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&size=690x400&sensor=false&center=#{location}&zoom=#{zoom}"
140
142
 
141
143
  else
142
144
  raise "unexpected url type #{type.inspect}"
@@ -10,7 +10,8 @@ module Onebox
10
10
  }
11
11
 
12
12
 
13
- matches_regexp Regexp.new("^http(?:s)?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
13
+ matches_regexp Regexp.new("^https?://play\\.(?:(?:\\w)+\\.)?(google)\\.com(?:/)?/store/apps/")
14
+ always_https
14
15
 
15
16
  private
16
17
 
@@ -5,6 +5,10 @@ module Onebox
5
5
 
6
6
  matches_regexp /^(https?:)?\/\/.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)(\?.*)?$/i
7
7
 
8
+ def always_https?
9
+ WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
10
+ end
11
+
8
12
  def to_html
9
13
  # Fix Dropbox image links
10
14
  if /^https:\/\/www.dropbox.com\/s\//.match @url
@@ -4,7 +4,7 @@ module Onebox
4
4
  include Engine
5
5
  include LayoutSupport
6
6
 
7
- matches_regexp Regexp.new("^http(?:s)?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/")
7
+ matches_regexp Regexp.new("^https?://(?:(?:\\w)+\\.)?(www.ncbi.nlm.nih)\\.gov(?:/)?/pubmed/")
8
8
 
9
9
  private
10
10
 
@@ -5,6 +5,7 @@ module Onebox
5
5
  include StandardEmbed
6
6
 
7
7
  matches_regexp(/^https?:\/\/.*soundcloud\.com/)
8
+ always_https
8
9
 
9
10
  def to_html
10
11
  get_oembed_data[:html].gsub!('height="400"', 'height="250"')
@@ -17,7 +18,7 @@ module Onebox
17
18
  private
18
19
 
19
20
  def get_oembed_data
20
- Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("http://soundcloud.com/oembed.json?url=#{url}").body))
21
+ Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response("https://soundcloud.com/oembed.json?url=#{url}").body))
21
22
  end
22
23
  end
23
24
  end
@@ -9,7 +9,11 @@ module Onebox
9
9
  %w(stackexchange stackoverflow superuser serverfault askubuntu)
10
10
  end
11
11
 
12
- matches_regexp /^http:\/\/(?:(?:(?<subsubdomain>\w*)\.)?(?<subdomain>\w*)\.)?(?<domain>#{domains.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
12
+ matches_regexp /^https?:\/\/(?:(?:(?<subsubdomain>\w*)\.)?(?<subdomain>\w*)\.)?(?<domain>#{domains.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
13
+
14
+ def always_https?
15
+ uri.host.split('.').length <= 3
16
+ end
13
17
 
14
18
  private
15
19
 
@@ -19,7 +23,7 @@ module Onebox
19
23
 
20
24
  def url
21
25
  domain = URI(@url).host
22
- "http://api.stackexchange.com/2.1/questions/#{match[:question]}?site=#{domain}"
26
+ "https://api.stackexchange.com/2.1/questions/#{match[:question]}?site=#{domain}"
23
27
  end
24
28
 
25
29
  def data
@@ -20,13 +20,18 @@ module Onebox
20
20
 
21
21
  # Some oembed providers (like meetup.com) don't provide links to themselves
22
22
  add_oembed_provider /www\.flickr\.com\//, 'http://www.flickr.com/services/oembed.json'
23
+ add_oembed_provider /(.*\.)?gfycat\.com\//, 'http://gfycat.com/cajax/oembed'
23
24
  add_oembed_provider /www\.kickstarter\.com\//, 'https://www.kickstarter.com/services/oembed'
24
25
  add_oembed_provider /www\.meetup\.com\//, 'http://api.meetup.com/oembed'
25
26
  add_oembed_provider /www\.ted\.com\//, 'http://www.ted.com/services/v1/oembed.json'
26
27
  add_oembed_provider /(.*\.)?vimeo\.com\//, 'http://vimeo.com/api/oembed.json'
27
28
 
28
29
  # Sites that work better with OpenGraph
29
- add_opengraph_provider /gfycat\.com\//
30
+ # add_opengraph_provider /gfycat\.com\//
31
+
32
+ def always_https?
33
+ WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
34
+ end
30
35
 
31
36
  def raw
32
37
  return @raw if @raw
@@ -5,7 +5,8 @@ module Onebox
5
5
  include LayoutSupport
6
6
  include HTML
7
7
 
8
- matches_regexp Regexp.new("^http(?:s)?://(?:www\\.)?(?:(?:\\w)+\\.)?(twitter)\\.com(?:/)?(?:.)*/status(es)?/")
8
+ matches_regexp Regexp.new("^https?://(?:www\\.)?(?:(?:\\w)+\\.)?(twitter)\\.com(?:/)?(?:.)*/status(es)?/")
9
+ always_https
9
10
 
10
11
  private
11
12
 
@@ -5,6 +5,10 @@ module Onebox
5
5
 
6
6
  matches_regexp /^(https?:)?\/\/.*\.(mov|mp4|webm|ogv)(\?.*)?$/
7
7
 
8
+ def always_https?
9
+ WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
10
+ end
11
+
8
12
  def to_html
9
13
  "<video width='100%' height='100%' controls><source src='#{@url}'><a href='#{@url}'>#{@url}</a></video>"
10
14
  end
@@ -142,17 +142,16 @@ module Onebox
142
142
  @html_providers = new_provs
143
143
  end
144
144
 
145
- # A re-written URL coverts https:// -> // - it is useful on HTTPS sites that embed
146
- # youtube for example
145
+ # A re-written URL coverts http:// -> https://
147
146
  def self.rewrites
148
- @rewrites ||= default_rewrites.dup
147
+ @rewrites ||= https_hosts.dup
149
148
  end
150
149
 
151
150
  def self.rewrites=(new_list)
152
151
  @rewrites = new_list
153
152
  end
154
153
 
155
- def self.default_rewrites
154
+ def self.https_hosts
156
155
  %w(slideshare.net imgur.com dailymotion.com livestream.com)
157
156
  end
158
157
 
@@ -187,11 +186,11 @@ module Onebox
187
186
  data[:type] == "article"
188
187
  end
189
188
 
190
- def rewrite_agnostic(html)
189
+ def rewrite_https(html)
191
190
  return html unless html
192
191
  uri = URI(@url)
193
192
  if WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.rewrites)
194
- html.gsub!(/https?:\/\//, '//')
193
+ html.gsub!(/http:\/\//, 'https://')
195
194
  end
196
195
  html
197
196
  end
@@ -217,7 +216,7 @@ module Onebox
217
216
  end
218
217
 
219
218
  def to_html
220
- rewrite_agnostic(generic_html)
219
+ rewrite_https(generic_html)
221
220
  end
222
221
 
223
222
  def placeholder_html
@@ -6,6 +6,7 @@ module Onebox
6
6
  include HTML
7
7
 
8
8
  matches_regexp(/^https?:\/\/.*wikipedia\.(com|org)/)
9
+ always_https
9
10
 
10
11
  private
11
12
 
@@ -5,6 +5,7 @@ module Onebox
5
5
  include StandardEmbed
6
6
 
7
7
  matches_regexp(/^https?:\/\/(?:www\.)?(?:m\.)?(?:youtube\.com|youtu\.be)\/.+$/)
8
+ always_https
8
9
 
9
10
  # Try to get the video ID. Works for URLs of the form:
10
11
  # * https://www.youtube.com/watch?v=Z0UISCEe52Y
@@ -58,7 +59,7 @@ module Onebox
58
59
  end
59
60
 
60
61
  def video_title
61
- yt_oembed_url = "http://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=#{video_id.split('?')[0]}"
62
+ yt_oembed_url = "https://www.youtube.com/oembed?format=json&url=https://www.youtube.com/watch?v=#{video_id.split('?')[0]}"
62
63
  yt_oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(yt_oembed_url).body))
63
64
  yt_oembed_data[:title]
64
65
  rescue
@@ -114,11 +115,6 @@ module Onebox
114
115
  end
115
116
  end
116
117
 
117
- # Note: May throw! Make sure to recue.
118
- def uri
119
- @_uri ||= URI(@url)
120
- end
121
-
122
118
  def params
123
119
  return {} unless uri.query
124
120
  # This mapping is necessary because CGI.parse returns a hash of keys to arrays.