imgix 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f024036dd9183dd1a68b09faf50a4115a1f67cb
4
- data.tar.gz: 2d6a4ccebcc9812512c00175afa578d55a34255a
3
+ metadata.gz: c065af1834dc3934c519fffe6ade364cae32993e
4
+ data.tar.gz: 96ea6ed38526442c99b6ff62a655ba75f8e44992
5
5
  SHA512:
6
- metadata.gz: 73f7c3044711d3382b067fdcdb8c6648a3572ad0f383eefc164b5005183e06b1057facb3eaca7ac83151a633b3d23d4e45b8fdfdf5162f5850a9a78790186516
7
- data.tar.gz: 11b9615037a7509fd579c94b1507c6eb2fa972ae8190da2b9366f07dbeea36f7e0c095c75c0b3138999cd97d6ba4e539dac6751ec4cda5e7cf18280df4ef0fcc
6
+ metadata.gz: c0272a45ae8ce8e0d496c345aa97228807f38aff0858aac459ffae0d1a166222f2dafc608c6e4f6a4bdc605e792795c89aded140fb56f9c38689de54f10868d3
7
+ data.tar.gz: 7c56ae3fd51c9d45dc2b37ca5d917ca9e3787e3101b43d169e6948d1437ef23fca425ce81b3d0176cd906125397a342d9c91aa2977531c0c864a4fec25aa93d6
@@ -1,8 +1,16 @@
1
1
  language: ruby
2
2
  bundler_args: --without development
3
3
  before_install:
4
- - gem install bundler
5
- - rvm get head
4
+ # Extracts the ruby version number
5
+ - RUBY_VERS="$(bc -l<<<$(ruby -v | cut -d' ' -f 2 | cut -d'.' -f 1,2))"
6
+ # Bundler 2.0 requires at least ruby vers 2.3.0
7
+ - LATEST_VERS=2.3
8
+ # Based on a given job's ruby version, install either
9
+ # Bundler 2.x or 1.17
10
+ - if (( $(echo "$RUBY_VERS >= $LATEST_VERS" | bc -l) ));
11
+ then echo $(gem install bundler);
12
+ else echo $(gem install bundler -v '< 2');
13
+ fi
6
14
  rvm:
7
15
  - 2.3.0
8
16
  - 2.2.4
@@ -3,6 +3,11 @@
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
+ ## [2.0.0] - February 25, 2019
7
+
8
+ * Add domain validation during Client initialization [#42](https://github.com/imgix/imgix-rb/pull/42)
9
+ * Expand Travis CI config to include bundler v2.x [#41](https://github.com/imgix/imgix-rb/pull/41)
10
+
6
11
  ## [1.2.2] - November 14, 2018
7
12
 
8
13
  * Improvements to memory usage [#35](https://github.com/imgix/imgix-rb/pull/35)
@@ -6,8 +6,8 @@ require 'imgix/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'imgix'
8
8
  spec.version = Imgix::VERSION
9
- spec.authors = ['Kelly Sutton', 'Sam Soffes', 'Ryan LeFevre', 'Antony Denyer', 'Paul Straw']
10
- spec.email = ['kelly@imgix.com', 'sam@soff.es', 'ryan@layervault.com', 'email@antonydenyer.co.uk', 'paul@imgix.com']
9
+ spec.authors = ['Kelly Sutton', 'Sam Soffes', 'Ryan LeFevre', 'Antony Denyer', 'Paul Straw', 'Sherwin Heydarbeygi']
10
+ spec.email = ['kelly@imgix.com', 'sam@soff.es', 'ryan@layervault.com', 'email@antonydenyer.co.uk', 'paul@imgix.com', 'sherwin@imgix.com']
11
11
  spec.description = 'Easily create and sign imgix URLs.'
12
12
  spec.summary = 'Official Ruby Gem for easily creating and signing imgix URLs.'
13
13
  spec.homepage = 'https://github.com/imgix/imgix-rb'
@@ -6,4 +6,5 @@ require 'imgix/path'
6
6
 
7
7
  module Imgix
8
8
  STRATEGIES = [:crc, :cycle]
9
+ DOMAIN_REGEX = /^(?:[a-z\d\-_]{1,62}\.){0,125}(?:[a-z\d](?:\-(?=\-*[a-z\d])|[a-z]|\d){0,62}\.)[a-z\d]{1,63}$/i
9
10
  end
@@ -49,7 +49,7 @@ module Imgix
49
49
  def get_host(path)
50
50
  host = host_for_crc(path) if @shard_strategy == :crc
51
51
  host = host_for_cycle if @shard_strategy == :cycle
52
- host.gsub("http://","").gsub("https://","").chomp("/")
52
+ host
53
53
  end
54
54
 
55
55
  def host_for_crc(path)
@@ -75,6 +75,11 @@ module Imgix
75
75
  unless @hosts.length > 0
76
76
  raise ArgumentError, "The :host or :hosts option must be specified"
77
77
  end
78
+ @hosts.each do |host|
79
+ if host.match(DOMAIN_REGEX) == nil
80
+ raise ArgumentError, "Domains must be passed in as fully-qualified domain names and should not include a protocol or any path element, i.e. \"example.imgix.net\"."
81
+ end
82
+ end
78
83
  end
79
84
 
80
85
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Imgix
4
- VERSION = '1.2.2'
4
+ VERSION = '2.0.0'
5
5
  end
@@ -42,24 +42,6 @@ class DomainsTest < Imgix::Test
42
42
  assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
43
43
  end
44
44
 
45
- def test_strips_out_protocol
46
- client = Imgix::Client.new(host: "http://demos-1.imgix.net",
47
- secure_url_token: '10adc394',
48
- include_library_param: false)
49
-
50
- path = client.path('/bridge.png')
51
- assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
52
- end
53
-
54
- def test_strips_out_trailing_slash
55
- client = Imgix::Client.new(host: "http://demos-1.imgix.net/",
56
- secure_url_token: '10adc394',
57
- include_library_param: false)
58
-
59
- path = client.path('/bridge.png')
60
- assert_equal 'https://demos-1.imgix.net/bridge.png?s=0233fd6de51f20f11cff6b452b7a9a05', path.to_url
61
- end
62
-
63
45
  def test_with_full_paths
64
46
  client = Imgix::Client.new(hosts: [
65
47
  "demos-1.imgix.net",
@@ -73,4 +55,16 @@ class DomainsTest < Imgix::Test
73
55
  path = 'https://google.com/cats.gif'
74
56
  assert_equal "https://demos-1.imgix.net/#{CGI.escape(path)}?s=e686099fbba86fc2b8141d3c1ff60605", client.path(path).to_url
75
57
  end
58
+
59
+ def test_invalid_domain_append_slash
60
+ assert_raises(ArgumentError) {Imgix::Client.new(hosts: ["assets.imgix.net/"])}
61
+ end
62
+
63
+ def test_invalid_domain_prepend_scheme
64
+ assert_raises(ArgumentError) {Imgix::Client.new(hosts: ["https://assets.imgix.net"])}
65
+ end
66
+
67
+ def test_invalid_domain_append_dash
68
+ assert_raises(ArgumentError) {Imgix::Client.new(hosts: ["assets.imgix.net-"])}
69
+ end
76
70
  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.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Sutton
@@ -9,10 +9,11 @@ authors:
9
9
  - Ryan LeFevre
10
10
  - Antony Denyer
11
11
  - Paul Straw
12
+ - Sherwin Heydarbeygi
12
13
  autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2018-11-14 00:00:00.000000000 Z
16
+ date: 2019-02-25 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: addressable
@@ -49,6 +50,7 @@ email:
49
50
  - ryan@layervault.com
50
51
  - email@antonydenyer.co.uk
51
52
  - paul@imgix.com
53
+ - sherwin@imgix.com
52
54
  executables: []
53
55
  extensions: []
54
56
  extra_rdoc_files: []
@@ -92,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
94
  version: '0'
93
95
  requirements: []
94
96
  rubyforge_project:
95
- rubygems_version: 2.5.2.3
97
+ rubygems_version: 2.6.13
96
98
  signing_key:
97
99
  specification_version: 4
98
100
  summary: Official Ruby Gem for easily creating and signing imgix URLs.