amp_helper 1.0.0.pre.1 → 1.0.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/amp_helper/amp_link_to_helper.rb +3 -2
- data/lib/amp_helper/configuration.rb +3 -1
- data/lib/amp_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de14bc07af417ab4acea00331539edcdd94cab90
|
4
|
+
data.tar.gz: b98de58c842a75f6e6e3d0187bd4d3eaa36ed3b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e1bd870f0d6dbbd001635e0105271271cba581241a8da96d38672e915aa57d2b1463cd3b0c933ec83de39d7e7a4ba2862384d02e1ebccf6f459e604f962531
|
7
|
+
data.tar.gz: 32182d37459945c0fef8f06f343792979d0a19f7bcf8491896ab732f47f87b7d9af6847feb199bbe395299a72a2a2c2db5b8d6afe56a5b8c90f0165c67bc3034
|
@@ -30,10 +30,11 @@ module AmpLinkToHelper
|
|
30
30
|
identify += "#{request.host}#{uri.path}#{uri.query}"
|
31
31
|
escaped_host = request.host.gsub('-', '--').gsub('.', '-')
|
32
32
|
cache_url = "https://#{escaped_host}.cdn.ampproject.org/c/#{identify}"
|
33
|
-
|
33
|
+
validate_amp_cache(cache_url) ? cache_url : uri.to_s
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def validate_amp_cache(url)
|
37
|
+
return true unless AmpHelper.configuration.confirm_cache_exist
|
37
38
|
Net::HTTP.get_response(URI(url)).code == '200'
|
38
39
|
end
|
39
40
|
end
|
@@ -9,12 +9,14 @@ module AmpHelper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class Configuration
|
12
|
-
attr_accessor :enable_amp_image, :format_2x, :enable_amp_link
|
12
|
+
attr_accessor :enable_amp_image, :format_2x, :enable_amp_link,
|
13
|
+
:confirm_cache_exist
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
@enable_amp_image = true
|
16
17
|
@format_2x = nil
|
17
18
|
@enable_amp_link = true
|
19
|
+
@confirm_cache_exist = false
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/amp_helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amp_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Awjecc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|