onebox 2.2.16 → 2.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/helpers.rb +1 -17
- data/lib/onebox/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3244779d201e9c64cb43a00dccfa5f189078c7b6b3523b3d262248a10bb9a4e1
|
4
|
+
data.tar.gz: c54ca691f2fc452e0a3d7865a91542f7214c2a430fd4959f8c825866f5bb18c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b36800f1d49b5c3eb0c6a8a81b06bf123bc5a051851576a41c3db4ebd4335bde92b60f34d5d674a4c34305c4197d42b09420cc9ecd940c36c2fbff950022fb5
|
7
|
+
data.tar.gz: 40f6f44ff3c4f7593e473260f26effeac3047e3342aad0d3e6264f83dc0fb9d45551342a8682323f5629a4944a89d4de0178f92f526766a7edb1b5aa535c717f
|
data/lib/onebox/helpers.rb
CHANGED
@@ -26,23 +26,7 @@ module Onebox
|
|
26
26
|
|
27
27
|
def self.fetch_html_doc(url, headers = nil, body_cacher = nil)
|
28
28
|
response = (fetch_response(url, headers: headers, body_cacher: body_cacher) rescue nil)
|
29
|
-
|
30
|
-
uri = Addressable::URI.parse(url)
|
31
|
-
|
32
|
-
ignore_canonical_tag = doc.at('meta[property="og:ignore_canonical"]')
|
33
|
-
should_ignore_canonical = IGNORE_CANONICAL_DOMAINS.map { |hostname| uri.hostname.match?(hostname) }.any?
|
34
|
-
|
35
|
-
unless (ignore_canonical_tag && ignore_canonical_tag['content'].to_s == 'true') || should_ignore_canonical
|
36
|
-
# prefer canonical link
|
37
|
-
canonical_link = doc.at('//link[@rel="canonical"]/@href')
|
38
|
-
canonical_uri = Addressable::URI.parse(canonical_link)
|
39
|
-
if canonical_link && "#{canonical_uri.host}#{canonical_uri.path}" != "#{uri.host}#{uri.path}"
|
40
|
-
response = (fetch_response(canonical_uri.to_s, headers: headers, body_cacher: body_cacher) rescue nil)
|
41
|
-
doc = Nokogiri::HTML(response) if response
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
doc
|
29
|
+
Nokogiri::HTML(response)
|
46
30
|
end
|
47
31
|
|
48
32
|
def self.fetch_response(location, redirect_limit: 5, domain: nil, headers: nil, body_cacher: nil)
|
data/lib/onebox/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
8
8
|
- Vyki Englert
|
9
9
|
- Robin Ward
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -407,7 +407,7 @@ homepage: https://github.com/discourse/onebox
|
|
407
407
|
licenses:
|
408
408
|
- MIT
|
409
409
|
metadata: {}
|
410
|
-
post_install_message:
|
410
|
+
post_install_message:
|
411
411
|
rdoc_options: []
|
412
412
|
require_paths:
|
413
413
|
- lib
|
@@ -423,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
423
423
|
version: '0'
|
424
424
|
requirements: []
|
425
425
|
rubygems_version: 3.0.3
|
426
|
-
signing_key:
|
426
|
+
signing_key:
|
427
427
|
specification_version: 4
|
428
428
|
summary: A gem for generating embeddable HTML previews from URLs.
|
429
429
|
test_files: []
|