onebox 1.8.67 → 1.8.68

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 852821c1793b34f5239b51d65cba8c1afa15167f53efb2c9383e2873cfd92acb
4
- data.tar.gz: 33e908e022f1df4d2653cf30d1f13f99f6fe215842e940b80b004a78ae2af81a
3
+ metadata.gz: 8ebcc562d8b0dcc66b83ddd79e1a3bcc47e2202686d8b96417a00e1a28b4bf3e
4
+ data.tar.gz: d7d3ba019ba3c50c02236b731e64981812cbd08ed51ef903d226fd31a7bc900c
5
5
  SHA512:
6
- metadata.gz: c04041b664eb183f2c822315ae1b95fb48a15865b55dea17857a80df4c87f1dedad6a77db39251e002e8adb4c65f567899f549b9af0f29e592d480dab369cb37
7
- data.tar.gz: 7499c8994ffc0f28db827a19280251f968e8357259dd08efb82583abf9f5258205f17ced26cf5e4f226feaa0c4ef2672649d4f76dd733ee05201353ad7f2d289
6
+ metadata.gz: 13eb57f76bd7419811a03149467fbf89d3ea4d587fae333e20a28cabd3087c315bf6ba6a08346e59060284b07289f83d4de1d05a678a0d6897a732cac066505b
7
+ data.tar.gz: 7d32c90c35c3ce018aadbf547b987ed034076ee8bdd15d6d5f90d6f7f6ba2716cc8ab2910d9b07d48acd0247c70bf51331f595b8c35295ae5f08c9892c8b74c8
@@ -19,9 +19,10 @@ module Onebox
19
19
 
20
20
  def video_html(og)
21
21
  escaped_src = ::Onebox::Helpers.normalize_url_for_output(og[:video_secure_url])
22
+ escaped_image_src = ::Onebox::Helpers.normalize_url_for_output(get_secure_link(og[:image]))
22
23
 
23
24
  <<-HTML
24
- <video width='#{og[:video_width]}' height='#{og[:video_height]}' #{Helpers.title_attr(og)} controls loop>
25
+ <video width='#{og[:video_width]}' height='#{og[:video_height]}' #{Helpers.title_attr(og)} poster="#{escaped_image_src}" controls loop>
25
26
  <source src='#{escaped_src}' type='video/mp4'>
26
27
  </video>
27
28
  HTML
@@ -122,18 +122,7 @@ module Onebox
122
122
  favicon = html_doc.css('link[rel="shortcut icon"], link[rel="icon shortcut"], link[rel="shortcut"], link[rel="icon"]').first
123
123
  favicon = favicon.nil? ? nil : (favicon['href'].nil? ? nil : favicon['href'].strip)
124
124
 
125
- if favicon && !!(favicon =~ /^\/\//)
126
- uri = URI(url)
127
- favicon = "#{uri.scheme}:#{favicon}"
128
- elsif favicon && favicon.match(/^https?:\/\//i).nil?
129
- uri = URI(url)
130
- favicon = if !favicon.start_with?("/") && uri.path.present?
131
- "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}#{uri.path.sub(/\/$/, '')}/#{favicon.sub(/^\//, '')}"
132
- else
133
- "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}/#{favicon.sub(/^\//, '')}"
134
- end
135
- end
136
- favicon
125
+ Onebox::Helpers::get_absolute_image_url(favicon, url)
137
126
  end
138
127
  end
139
128
  end
@@ -218,6 +218,8 @@ module Onebox
218
218
 
219
219
  # prefer secure URLs
220
220
  d[:image] = d[:image_secure_url] || d[:image_url] || d[:thumbnail_url] || d[:image]
221
+ d[:image] = Onebox::Helpers::get_absolute_image_url(d[:image], @url)
222
+
221
223
  d[:video] = d[:video_secure_url] || d[:video_url] || d[:video]
222
224
 
223
225
  d[:published_time] = d[:article_published_time] unless Onebox::Helpers.blank?(d[:article_published_time])
@@ -187,5 +187,19 @@ module Onebox
187
187
  url
188
188
  end
189
189
 
190
+ def self.get_absolute_image_url(src, url)
191
+ if src && !!(src =~ /^\/\//)
192
+ uri = URI(url)
193
+ src = "#{uri.scheme}:#{src}"
194
+ elsif src && src.match(/^https?:\/\//i).nil?
195
+ uri = URI(url)
196
+ src = if !src.start_with?("/") && uri.path.present?
197
+ "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}#{uri.path.sub(/\/$/, '')}/#{src.sub(/^\//, '')}"
198
+ else
199
+ "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}/#{src.sub(/^\//, '')}"
200
+ end
201
+ end
202
+ src
203
+ end
190
204
  end
191
205
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "1.8.67"
4
+ VERSION = "1.8.68"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.67
4
+ version: 1.8.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-09 00:00:00.000000000 Z
13
+ date: 2018-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json