imgix 1.0.0 → 1.1.0

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: 027c32d72ff3ee11467364ed4771838dc324f134
4
- data.tar.gz: 6df850a7689330e587aa81f536f4308d7c0cb50f
3
+ metadata.gz: 8c573b0b53304a06886cb1848fd233109975021d
4
+ data.tar.gz: ab4b939716370098523381acbcbd3817fdc63b02
5
5
  SHA512:
6
- metadata.gz: 8bc8ca0fafa2733e9c4d2716793c07e3221add977a5870f462410fe414d350b73ac907353a00188fe5457966cec9b624628752f07c663941f9ea0cd46f6b1811
7
- data.tar.gz: d17301a5b9a127d8cac312eeaca33c01aa2ec9af693f8003acb20334b5425b3667bb815b5e3bdf06a32da2972c047372c5f700191d021345d4d737ac7703ad47
6
+ metadata.gz: ef8647b9485547eb1af90b6b7d6758099d7028c72745ab55c37f31076a657ed9a4a88872708137b62101bb5b1aa7b940b9673300cc845dc8d72fd9585cac1cd2
7
+ data.tar.gz: c0b9567ab4201cb685ce94da7d1d61e2e55af6692d83ac916bfc964e5fca97b1cc4b807071353ab797ea2f803aa0f532cb70dfbd64f97cdd58f8dcec7c4b8b1f
@@ -1,8 +1,11 @@
1
1
  language: ruby
2
2
  bundler_args: --without development
3
- before_install: gem install bundler
3
+ before_install:
4
+ - gem install bundler
5
+ - rvm get head
4
6
  rvm:
5
- - 2.2.2
6
- - 1.9.2
7
- - jruby-1.7.19
8
- - rbx-2.2.7
7
+ - 2.3.0
8
+ - 2.2.4
9
+ - 2.1.8
10
+ - jruby-9.0.5.0
11
+ - rbx-2.11
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [1.1.0] - February 24, 2016
7
+
8
+ * Added automatic Base64 encoding for all Base64 variant parameters.
9
+ * Properly encoding all keys and values output by `Imgix::Path`.
10
+ * Better URL encoding for spaces, with `ERB::Util.url_encode`.
11
+ * Normalize trailing `/` in passed hosts.
12
+
6
13
  ## [1.0.0] - December 9, 2015
7
14
  ### Changed
8
15
  - Removed `Client#sign_path` to provide a consistent method and code path for generating URLs. [#16](https://github.com/imgix/imgix-rb/issues/16)
data/README.md CHANGED
@@ -72,7 +72,7 @@ client = Imgix::Client.new(hosts: ['your-subdomain-1.imgix.net',
72
72
 
73
73
  When the imgix api requires multiple parameters you have to use the method rather than an accessor.
74
74
 
75
- For example to use the [noise reduction](http://www.imgix.com/docs/urlapi/enhance#nr-nrs) options:
75
+ For example to use the noise reduction:
76
76
 
77
77
  ``` ruby
78
78
  path.noise_reduction(50,50)
@@ -31,7 +31,7 @@ module Imgix
31
31
  def get_host(path)
32
32
  host = host_for_crc(path) if @shard_strategy == :crc
33
33
  host = host_for_cycle if @shard_strategy == :cycle
34
- host.gsub("http://","").gsub("https://","")
34
+ host.gsub("http://","").gsub("https://","").chomp("/")
35
35
  end
36
36
 
37
37
  def host_for_crc(path)
@@ -1,4 +1,6 @@
1
+ require 'base64'
1
2
  require 'cgi/util'
3
+ require 'erb'
2
4
  require 'imgix/param_helpers'
3
5
 
4
6
  module Imgix
@@ -90,7 +92,16 @@ module Imgix
90
92
  end
91
93
 
92
94
  def query
93
- @options.map { |k, v| "#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&')
95
+ @options.map do |key, val|
96
+ escaped_key = ERB::Util.url_encode(key.to_s)
97
+
98
+ if escaped_key.end_with? '64'
99
+ base64_encoded_val = Base64.urlsafe_encode64(val.to_s).delete('=')
100
+ "#{escaped_key}=#{base64_encoded_val}"
101
+ else
102
+ "#{escaped_key}=#{ERB::Util.url_encode(val.to_s)}"
103
+ end
104
+ end.join('&')
94
105
  end
95
106
 
96
107
  def has_query?
@@ -1,3 +1,3 @@
1
1
  module Imgix
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -1,7 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class DomainsTest < Imgix::Test
4
-
5
4
  def test_deterministically_choosing_a_path
6
5
  client = Imgix::Client.new(hosts: [
7
6
  "demos-1.imgix.net",
@@ -50,6 +49,15 @@ class DomainsTest < Imgix::Test
50
49
  assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
51
50
  end
52
51
 
52
+ def test_strips_out_trailing_slash
53
+ client = Imgix::Client.new(host: "http://demos-1.imgix.net/",
54
+ secure_url_token: '10adc394',
55
+ include_library_param: false)
56
+
57
+ path = client.path('/bridge.png')
58
+ assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
59
+ end
60
+
53
61
  def test_with_full_paths
54
62
  client = Imgix::Client.new(hosts: [
55
63
  "demos-1.imgix.net",
@@ -48,6 +48,30 @@ class PathTest < Imgix::Test
48
48
  assert_equal url, path.markalign('middle', 'center').to_url
49
49
  end
50
50
 
51
+ def test_param_keys_are_escaped
52
+ ix_url = unsigned_client.path('demo.png').to_url({
53
+ :'hello world' => 'interesting'
54
+ })
55
+
56
+ assert_equal "https://demo.imgix.net/demo.png?hello%20world=interesting", ix_url
57
+ end
58
+
59
+ def test_param_values_are_escaped
60
+ ix_url = unsigned_client.path('demo.png').to_url({
61
+ hello_world: '/foo"> <script>alert("hacked")</script><'
62
+ })
63
+
64
+ assert_equal "https://demo.imgix.net/demo.png?hello_world=%2Ffoo%22%3E%20%3Cscript%3Ealert%28%22hacked%22%29%3C%2Fscript%3E%3C", ix_url
65
+ end
66
+
67
+ def test_base64_param_variants_are_base64_encoded
68
+ ix_url = unsigned_client.path('~text').to_url({
69
+ txt64: 'I cannøt belîév∑ it wors! 😱'
70
+ })
71
+
72
+ assert_equal "https://demo.imgix.net/~text?txt64=SSBjYW5uw7h0IGJlbMOuw6l24oiRIGl0IHdvcu-jv3MhIPCfmLE", ix_url
73
+ end
74
+
51
75
  def test_host_is_required
52
76
  assert_raises(ArgumentError) {Imgix::Client.new}
53
77
  end
@@ -88,7 +112,7 @@ class PathTest < Imgix::Test
88
112
 
89
113
  def test_configure_library_param
90
114
  library = "sinatra"
91
- version = "1.0.0"
115
+ version = Imgix::VERSION
92
116
  client = Imgix::Client.new(host: 'demo.imgix.net', library_param: library, library_version: version) # enabled by default
93
117
  url = client.path('/images/demo.png').to_url
94
118
 
@@ -96,8 +120,11 @@ class PathTest < Imgix::Test
96
120
  end
97
121
 
98
122
  private
99
-
100
123
  def client
101
124
  @client ||= Imgix::Client.new(host: 'demo.imgix.net', secure_url_token: '10adc394', include_library_param: false)
102
125
  end
126
+
127
+ def unsigned_client
128
+ @unsigned_client ||= Imgix::Client.new(host: 'demo.imgix.net', include_library_param: false)
129
+ end
103
130
  end
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-12-09 00:00:00.000000000 Z
15
+ date: 2016-02-24 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable