rack-canonical-host 0.2.3 → 1.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
- SHA1:
3
- metadata.gz: d3d9c586fbafde39480ab18a92bdb843db3b156c
4
- data.tar.gz: 3c250e72ab7a6d4a6ff449a36f4a7377166e8f82
2
+ SHA256:
3
+ metadata.gz: 36437f7276540d9097e0dfaccebde73e146de68039a3477013f94d2c96f5a2d9
4
+ data.tar.gz: bb2183b48c3379140f7119eb410c9b9b6a64ec2dd8ed9a7e0a5a86a01ef63e76
5
5
  SHA512:
6
- metadata.gz: c845c4018a0eee4a644ab6ab008ca5f79efbbdc63af07852804f4c27583812eb4226fff89d70e7f6615eb7d1091a538e382f36848512dce3c799a659ee29fb56
7
- data.tar.gz: fcd94a1908c05108707ce73dc22ff3a746ff637adb11af607b8554d05075cceec0e2af9490a0c6f4c71debc4495a92c90b8680b8da833896290fcec4afa3a98e
6
+ metadata.gz: 797fd843b45adb8ce8abff067c04d52792fbafb2a4752120b9b3f56502dc6c5e4c51356f810831a3199a13f00df33935139ef38a5186ea6a866f0851fe6d822b
7
+ data.tar.gz: d8733e910110b3dc6365ea862bbdb3e87984c34de9581adc27ce7ee3dcfc36661f1415b080845b24e74fa1eef853c1a75096b74bec65834338fb86e3760db93a
@@ -7,17 +7,15 @@ gemfile:
7
7
  - gemfiles/rack_1.5.gemfile
8
8
  - gemfiles/rack_1.6.gemfile
9
9
  - gemfiles/rack_2.0.gemfile
10
+ - gemfiles/rack_2.1.gemfile
11
+ - gemfiles/rack_2.2.gemfile
10
12
 
11
13
  rvm:
12
- - 2.0.0
13
- - 2.1.10
14
- - 2.2.7
15
- - 2.3.4
16
- - 2.4.1
14
+ - 2.3.8
15
+ - 2.4.9
16
+ - 2.5.8
17
+ - 2.6.5
18
+ - 2.7.0
17
19
 
18
- matrix:
19
- exclude:
20
- - rvm: 2.0.0
21
- gemfile: gemfiles/rack_2.0.gemfile
22
- - rvm: 2.1.10
23
- gemfile: gemfiles/rack_2.0.gemfile
20
+ before_install:
21
+ - gem install bundler -v 1.17.2
data/Appraisals CHANGED
@@ -1,11 +1,19 @@
1
1
  appraise 'rack-1.5' do
2
- gem 'rack', '~> 1.5'
2
+ gem 'rack', '~> 1.5.0'
3
3
  end
4
4
 
5
5
  appraise 'rack-1.6' do
6
- gem 'rack', '~> 1.6'
6
+ gem 'rack', '~> 1.6.0'
7
7
  end
8
8
 
9
9
  appraise 'rack-2.0' do
10
- gem 'rack', '~> 2.0'
10
+ gem 'rack', '~> 2.0.0'
11
+ end
12
+
13
+ appraise 'rack-2.1' do
14
+ gem 'rack', '~> 2.1.0'
15
+ end
16
+
17
+ appraise 'rack-2.2' do
18
+ gem 'rack', '~> 2.2.0'
11
19
  end
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0 (2020-04-16)
4
+
5
+ * Use equality to determine string matches on `:if` and `:ignore`
6
+
3
7
  ## 0.2.3 (2017-04-20)
4
8
 
5
9
  * Add regexp support for `:ignore` option ([Daniel Searles][squaresurf])
@@ -73,7 +77,7 @@
73
77
  [jschuur]: http://github.com/jschuur
74
78
  [nbibler]: http://github.com/nbibler
75
79
  [rubymaverick]: http://github.com/ericallam
76
- [squaresurfSearles]: https://github.com/squaresurf
80
+ [squaresurf]: https://github.com/squaresurf
77
81
  [tma]: http://github.com/tma
78
82
  [tylerhunt]: http://github.com/tylerhunt
79
83
  [zoso10]: http://github.com/zoso10
data/README.md CHANGED
@@ -4,10 +4,9 @@ Rack middleware that lets you define a single host name as the canonical host
4
4
  for your application. Requests for other host names will then be redirected to
5
5
  the canonical host.
6
6
 
7
- [![Gem Version](https://img.shields.io/gem/v/rack-canonical-host.svg)](http://rubygems.org/gems/rack-canonical-host)
8
- [![Build Status](https://img.shields.io/travis/tylerhunt/rack-canonical-host/master.svg)](https://travis-ci.org/tylerhunt/rack-canonical-host)
9
- [![Code Climate](https://img.shields.io/codeclimate/github/tylerhunt/rack-canonical-host.svg)](https://codeclimate.com/github/tylerhunt/rack-canonical-host)
10
- [![Dependency Status](https://gemnasium.com/tylerhunt/rack-canonical-host.svg)](https://gemnasium.com/tylerhunt/rack-canonical-host)
7
+ [![Gem Version](https://img.shields.io/gem/v/rack-canonical-host)](http://rubygems.org/gems/rack-canonical-host)
8
+ [![Build Status](https://img.shields.io/travis/tylerhunt/rack-canonical-host)](https://travis-ci.org/tylerhunt/rack-canonical-host)
9
+ [![Code Climate](https://img.shields.io/codeclimate/maintainability/tylerhunt/rack-canonical-host)](https://codeclimate.com/github/tylerhunt/rack-canonical-host)
11
10
 
12
11
  ## Installation
13
12
 
@@ -35,6 +34,7 @@ Here’s a simple example of what the `config.ru` in a Rails application might
35
34
  look like after adding the `Rack::CanonicalHost` middleware.
36
35
 
37
36
  ```ruby
37
+ require 'rack/canonical_host'
38
38
  require ::File.expand_path('../config/environment', __FILE__)
39
39
 
40
40
  use Rack::CanonicalHost, 'example.com'
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rack", "~> 1.5"
5
+ gem "rack", "~> 1.5.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rack-canonical-host (1.0.0)
5
+ addressable (> 0, < 3)
6
+ rack (>= 1.0.0, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ appraisal (2.2.0)
14
+ bundler
15
+ rake
16
+ thor (>= 0.14.0)
17
+ diff-lcs (1.3)
18
+ public_suffix (4.0.4)
19
+ rack (1.5.5)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thor (1.0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ appraisal (~> 2.2)
41
+ rack (~> 1.5.0)
42
+ rack-canonical-host!
43
+ rake
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rack", "~> 1.6"
5
+ gem "rack", "~> 1.6.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rack-canonical-host (1.0.0)
5
+ addressable (> 0, < 3)
6
+ rack (>= 1.0.0, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ appraisal (2.2.0)
14
+ bundler
15
+ rake
16
+ thor (>= 0.14.0)
17
+ diff-lcs (1.3)
18
+ public_suffix (4.0.4)
19
+ rack (1.6.13)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thor (1.0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ appraisal (~> 2.2)
41
+ rack (~> 1.6.0)
42
+ rack-canonical-host!
43
+ rake
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rack", "~> 2.0"
5
+ gem "rack", "~> 2.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rack-canonical-host (1.0.0)
5
+ addressable (> 0, < 3)
6
+ rack (>= 1.0.0, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ appraisal (2.2.0)
14
+ bundler
15
+ rake
16
+ thor (>= 0.14.0)
17
+ diff-lcs (1.3)
18
+ public_suffix (4.0.4)
19
+ rack (2.0.9)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thor (1.0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ appraisal (~> 2.2)
41
+ rack (~> 2.0.0)
42
+ rack-canonical-host!
43
+ rake
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 2.1.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rack-canonical-host (1.0.0)
5
+ addressable (> 0, < 3)
6
+ rack (>= 1.0.0, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ appraisal (2.2.0)
14
+ bundler
15
+ rake
16
+ thor (>= 0.14.0)
17
+ diff-lcs (1.3)
18
+ public_suffix (4.0.4)
19
+ rack (2.1.2)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thor (1.0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ appraisal (~> 2.2)
41
+ rack (~> 2.1.0)
42
+ rack-canonical-host!
43
+ rake
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rack", "~> 2.2.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rack-canonical-host (1.0.0)
5
+ addressable (> 0, < 3)
6
+ rack (>= 1.0.0, < 3)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ appraisal (2.2.0)
14
+ bundler
15
+ rake
16
+ thor (>= 0.14.0)
17
+ diff-lcs (1.3)
18
+ public_suffix (4.0.4)
19
+ rack (2.2.2)
20
+ rake (13.0.1)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.1)
26
+ rspec-support (~> 3.9.1)
27
+ rspec-expectations (3.9.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.2)
34
+ thor (1.0.1)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ appraisal (~> 2.2)
41
+ rack (~> 2.2.0)
42
+ rack-canonical-host!
43
+ rake
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -42,8 +42,14 @@ module Rack
42
42
 
43
43
  private
44
44
 
45
- def any_match?(patterns, string)
46
- patterns.any? { |pattern| string[pattern] }
45
+ def any_match?(patterns, host)
46
+ patterns.any? { |pattern|
47
+ case pattern
48
+ when Regexp then host =~ pattern
49
+ when String then host == pattern
50
+ else false
51
+ end
52
+ }
47
53
  end
48
54
 
49
55
  def headers
@@ -57,15 +63,13 @@ module Rack
57
63
  def enabled?
58
64
  return true if conditions.empty?
59
65
 
60
- conditions.include?(request_uri.host) ||
61
- any_match?(conditions, request_uri.host)
66
+ any_match?(conditions, request_uri.host)
62
67
  end
63
68
 
64
69
  def ignored?
65
70
  return false if ignore.empty?
66
71
 
67
- ignore.include?(request_uri.host) ||
68
- any_match?(ignore, request_uri.host)
72
+ any_match?(ignore, request_uri.host)
69
73
  end
70
74
 
71
75
  def known?
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class CanonicalHost
3
- VERSION = '0.2.3'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -110,71 +110,75 @@ RSpec.describe Rack::CanonicalHost do
110
110
  include_context 'a matching request'
111
111
  end
112
112
 
113
- context 'with :ignore string option' do
114
- let(:app) { build_app('example.com', :ignore => 'example.net') }
113
+ context 'with :ignore option' do
114
+ context 'with string' do
115
+ let(:app) { build_app('example.com', :ignore => 'example.net') }
115
116
 
116
- include_context 'a matching request'
117
- include_context 'a non-matching request'
117
+ include_context 'a matching request'
118
+ include_context 'a non-matching request'
118
119
 
119
- context 'with a request to an ignored host' do
120
- let(:url) { 'http://example.net/full/path' }
120
+ context 'with a request to an ignored host' do
121
+ let(:url) { 'http://example.net/full/path' }
121
122
 
122
- it { should_not be_redirect }
123
+ it { should_not be_redirect }
123
124
 
124
- it 'calls the inner app' do
125
- expect(inner_app).to receive(:call).with(env)
126
- call_app
125
+ it 'calls the inner app' do
126
+ expect(inner_app).to receive(:call).with(env)
127
+ call_app
128
+ end
127
129
  end
128
130
  end
129
- end
130
131
 
131
- context 'with :ignore regex option' do
132
- let(:app) { build_app('example.com', :ignore => /ex.*\.net/) }
132
+ context 'with regular expression' do
133
+ let(:app) { build_app('example.com', :ignore => /ex.*\.net/) }
133
134
 
134
- include_context 'a matching request'
135
- include_context 'a non-matching request'
135
+ include_context 'a matching request'
136
+ include_context 'a non-matching request'
136
137
 
137
- context 'with a request to an ignored host' do
138
- let(:url) { 'http://example.net/full/path' }
138
+ context 'with a request to an ignored host' do
139
+ let(:url) { 'http://example.net/full/path' }
139
140
 
140
- it { should_not be_redirect }
141
+ it { should_not be_redirect }
141
142
 
142
- it 'calls the inner app' do
143
- expect(inner_app).to receive(:call).with(env)
144
- call_app
143
+ it 'calls the inner app' do
144
+ expect(inner_app).to receive(:call).with(env)
145
+ call_app
146
+ end
145
147
  end
146
148
  end
147
149
  end
148
150
 
149
151
  context 'with :if option' do
150
- let(:app) { build_app('example.com', :if => 'www.example.net') }
152
+ context 'with string' do
153
+ let(:app) { build_app('www.example.com', :if => 'example.com') }
151
154
 
152
- context 'with a request to a matching host' do
153
- let(:url) { 'http://www.example.net/full/path' }
155
+ context 'with a request to a matching host' do
156
+ let(:url) { 'http://example.com/full/path' }
154
157
 
155
- it { should redirect_to('http://example.com/full/path') }
156
- end
158
+ it { should redirect_to('http://www.example.com/full/path') }
159
+ end
157
160
 
158
- context 'with a request to a non-matching host' do
159
- let(:url) { 'http://www.example.com/full/path' }
161
+ context 'with a request to a non-matching host' do
162
+ let(:url) { 'http://api.example.com/full/path' }
160
163
 
161
- it { should_not be_redirect }
164
+ it { should_not be_redirect }
165
+ end
162
166
  end
163
- end
164
167
 
165
- context 'with a regular expression :if option' do
166
- let(:app) { build_app('example.com', :if => /.*\.example\.net/) }
168
+ context 'with a regular expression' do
169
+ let(:app) { build_app('example.com', :if => '.*\.example\.com') }
167
170
 
168
- context 'with a request to a matching host' do
169
- let(:url) { 'http://subdomain.example.net/full/path' }
171
+ context 'with a request to a matching host' do
172
+ let(:url) { 'http://www.example.com/full/path' }
170
173
 
171
- it { should redirect_to('http://example.com/full/path') }
172
- end
174
+ it { should_not redirect_to('http://example.com/full/path') }
175
+ end
173
176
 
174
- context 'with a request to a non-matching host' do
175
- let(:url) { 'http://example.net/full/path' }
177
+ context 'with a request to a non-matching host' do
178
+ let(:url) { 'http://www.example.net/full/path' }
176
179
 
177
- it { should_not be_redirect }
180
+ it { should_not be_redirect }
181
+ end
178
182
  end
179
183
  end
180
184
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-canonical-host
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Hunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-20 00:00:00.000000000 Z
11
+ date: 2020-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -108,8 +108,15 @@ files:
108
108
  - README.md
109
109
  - Rakefile
110
110
  - gemfiles/rack_1.5.gemfile
111
+ - gemfiles/rack_1.5.gemfile.lock
111
112
  - gemfiles/rack_1.6.gemfile
113
+ - gemfiles/rack_1.6.gemfile.lock
112
114
  - gemfiles/rack_2.0.gemfile
115
+ - gemfiles/rack_2.0.gemfile.lock
116
+ - gemfiles/rack_2.1.gemfile
117
+ - gemfiles/rack_2.1.gemfile.lock
118
+ - gemfiles/rack_2.2.gemfile
119
+ - gemfiles/rack_2.2.gemfile.lock
113
120
  - lib/rack-canonical-host.rb
114
121
  - lib/rack/canonical_host.rb
115
122
  - lib/rack/canonical_host/redirect.rb
@@ -137,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
144
  - !ruby/object:Gem::Version
138
145
  version: '0'
139
146
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.6.8
147
+ rubygems_version: 3.0.3
142
148
  signing_key:
143
149
  specification_version: 4
144
150
  summary: Rack middleware for defining a canonical host name.