imgix 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/imgix/client.rb +6 -2
- data/lib/imgix/path.rb +6 -4
- data/lib/imgix/version.rb +1 -1
- data/test/units/path_test.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d47d95ae9a8393382dad40adde1d7334d0ec6b0
|
4
|
+
data.tar.gz: d9d9468847c4794d1df05d1a518bfe734467fe64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc7a9a75834d9bc26cb3f9433122cf4149d175e634c248e75dd345c393f04ffecdbd5a7506cf2133a15c68f84f9ca837133a5f83b940b0d80f195c1f5a18f9a
|
7
|
+
data.tar.gz: cc809d26b35e0362bcc95153171a9d34ab5fc92b4d69df20f1911961133a861bb4bac4d3a5ae16a42c1a7c59b3b5ed2d03c3eb460bd11d122977d3d15533c724
|
data/lib/imgix/client.rb
CHANGED
@@ -26,8 +26,12 @@ module Imgix
|
|
26
26
|
def sign_path(path)
|
27
27
|
uri = Addressable::URI.parse(path)
|
28
28
|
query = (uri.query || '')
|
29
|
-
|
30
|
-
|
29
|
+
path = "#{@secure ? 'https' : 'http'}://#{get_host(path)}#{uri.path}?#{query}"
|
30
|
+
if @token
|
31
|
+
signature = Digest::MD5.hexdigest(@token + uri.path + '?' + query)
|
32
|
+
path += "&s=#{signature}"
|
33
|
+
end
|
34
|
+
return path
|
31
35
|
end
|
32
36
|
|
33
37
|
def get_host(path)
|
data/lib/imgix/path.rb
CHANGED
@@ -42,10 +42,12 @@ module Imgix
|
|
42
42
|
|
43
43
|
url = @prefix + path_and_params
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
if @token
|
46
|
+
# Weird bug in imgix. If there are no params, you still have
|
47
|
+
# to put & in front of the signature or else you will get
|
48
|
+
# unauthorized.
|
49
|
+
url += "&s=#{signature}"
|
50
|
+
end
|
49
51
|
|
50
52
|
@options = prev_options
|
51
53
|
return url
|
data/lib/imgix/version.rb
CHANGED
data/test/units/path_test.rb
CHANGED
@@ -52,6 +52,14 @@ class PathTest < Imgix::Test
|
|
52
52
|
assert_raises(ArgumentError) {Imgix::Client.new}
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_token_is_optional
|
56
|
+
client = Imgix::Client.new(host: 'demo.imgix.net')
|
57
|
+
url = 'http://demo.imgix.net/images/demo.png?'
|
58
|
+
path = client.path('/images/demo.png')
|
59
|
+
|
60
|
+
assert_equal url, path.to_url
|
61
|
+
end
|
62
|
+
|
55
63
|
private
|
56
64
|
|
57
65
|
def client
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imgix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Soffes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.4.
|
75
|
+
rubygems_version: 2.4.6
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Unofficial Ruby Gem for easily signing imgix URLs.
|