imgix 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a760faaa0b10815f6507106c11fae9ef28ab574
4
- data.tar.gz: f08596f57d3bc94cbc3f30a8f597c858ab154c80
3
+ metadata.gz: 4d47d95ae9a8393382dad40adde1d7334d0ec6b0
4
+ data.tar.gz: d9d9468847c4794d1df05d1a518bfe734467fe64
5
5
  SHA512:
6
- metadata.gz: 535a0f0626342197b5435564ed7d15af4163b8cbe11c6cba57da5dd6193965a3e0c4cc8f0b795448c7ee8ea1df991a4cdb142134c3c9a33f35adfbb4b8b28158
7
- data.tar.gz: 6b41e460a3698bd90a9723fea1ddc43f75db4b6c19f1f5d48e4307aa8a9dee6a1de1e2d6e228c20b53a3bb5a99d406dbe33e2e61dc065c26c4169c62b5c2bd8f
6
+ metadata.gz: 3bc7a9a75834d9bc26cb3f9433122cf4149d175e634c248e75dd345c393f04ffecdbd5a7506cf2133a15c68f84f9ca837133a5f83b940b0d80f195c1f5a18f9a
7
+ data.tar.gz: cc809d26b35e0362bcc95153171a9d34ab5fc92b4d69df20f1911961133a861bb4bac4d3a5ae16a42c1a7c59b3b5ed2d03c3eb460bd11d122977d3d15533c724
@@ -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
- signature = Digest::MD5.hexdigest(@token + uri.path + '?' + query)
30
- "#{@secure ? 'https' : 'http'}://#{get_host(path)}#{uri.path}?#{query}&s=#{signature}"
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)
@@ -42,10 +42,12 @@ module Imgix
42
42
 
43
43
  url = @prefix + path_and_params
44
44
 
45
- # Weird bug in imgix. If there are no params, you still have
46
- # to put & in front of the signature or else you will get
47
- # unauthorized.
48
- url += "&s=#{signature}"
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
@@ -1,3 +1,3 @@
1
1
  module Imgix
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -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.1
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-03-03 00:00:00.000000000 Z
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.5
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.