rack-canonical-host 0.2.2 → 0.2.3
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 +4 -4
- data/.travis.yml +17 -3
- data/Appraisals +11 -0
- data/CHANGELOG.md +5 -0
- data/README.md +17 -15
- data/gemfiles/rack_1.5.gemfile +7 -0
- data/gemfiles/rack_1.6.gemfile +7 -0
- data/gemfiles/rack_2.0.gemfile +7 -0
- data/lib/rack/canonical_host/redirect.rb +4 -1
- data/lib/rack/canonical_host/version.rb +1 -1
- data/rack-canonical-host.gemspec +1 -0
- data/spec/rack/canonical_host_spec.rb +19 -1
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3d9c586fbafde39480ab18a92bdb843db3b156c
|
4
|
+
data.tar.gz: 3c250e72ab7a6d4a6ff449a36f4a7377166e8f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c845c4018a0eee4a644ab6ab008ca5f79efbbdc63af07852804f4c27583812eb4226fff89d70e7f6615eb7d1091a538e382f36848512dce3c799a659ee29fb56
|
7
|
+
data.tar.gz: fcd94a1908c05108707ce73dc22ff3a746ff637adb11af607b8554d05075cceec0e2af9490a0c6f4c71debc4495a92c90b8680b8da833896290fcec4afa3a98e
|
data/.travis.yml
CHANGED
@@ -2,8 +2,22 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
script: bundle exec rspec
|
4
4
|
sudo: false
|
5
|
+
|
6
|
+
gemfile:
|
7
|
+
- gemfiles/rack_1.5.gemfile
|
8
|
+
- gemfiles/rack_1.6.gemfile
|
9
|
+
- gemfiles/rack_2.0.gemfile
|
10
|
+
|
5
11
|
rvm:
|
6
|
-
- 1.9.3
|
7
12
|
- 2.0.0
|
8
|
-
- 2.1.
|
9
|
-
- 2.
|
13
|
+
- 2.1.10
|
14
|
+
- 2.2.7
|
15
|
+
- 2.3.4
|
16
|
+
- 2.4.1
|
17
|
+
|
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
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.3 (2017-04-20)
|
4
|
+
|
5
|
+
* Add regexp support for `:ignore` option ([Daniel Searles][squaresurf])
|
6
|
+
|
3
7
|
## 0.2.2 (2016-05-17)
|
4
8
|
|
5
9
|
* Add `:cache_control` option ([Pete Nicholls][Aupajo])
|
@@ -69,6 +73,7 @@
|
|
69
73
|
[jschuur]: http://github.com/jschuur
|
70
74
|
[nbibler]: http://github.com/nbibler
|
71
75
|
[rubymaverick]: http://github.com/ericallam
|
76
|
+
[squaresurfSearles]: https://github.com/squaresurf
|
72
77
|
[tma]: http://github.com/tma
|
73
78
|
[tylerhunt]: http://github.com/tylerhunt
|
74
79
|
[zoso10]: http://github.com/zoso10
|
data/README.md
CHANGED
@@ -11,9 +11,9 @@ the canonical host.
|
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
|
14
|
-
Add this line to your application
|
14
|
+
Add this line to your application’s `Gemfile`:
|
15
15
|
|
16
|
-
```
|
16
|
+
```ruby
|
17
17
|
gem 'rack-canonical-host'
|
18
18
|
```
|
19
19
|
|
@@ -31,10 +31,10 @@ Or install it yourself as:
|
|
31
31
|
For most applications, you can insert the middleware into the `config.ru` file
|
32
32
|
in the root of the application.
|
33
33
|
|
34
|
-
Here
|
34
|
+
Here’s a simple example of what the `config.ru` in a Rails application might
|
35
35
|
look like after adding the `Rack::CanonicalHost` middleware.
|
36
36
|
|
37
|
-
```
|
37
|
+
```ruby
|
38
38
|
require ::File.expand_path('../config/environment', __FILE__)
|
39
39
|
|
40
40
|
use Rack::CanonicalHost, 'example.com'
|
@@ -57,7 +57,7 @@ With Heroku, you would do this like so:
|
|
57
57
|
|
58
58
|
Then, can configure the middleware like this:
|
59
59
|
|
60
|
-
```
|
60
|
+
```ruby
|
61
61
|
use Rack::CanonicalHost, ENV['CANONICAL_HOST'] if ENV['CANONICAL_HOST']
|
62
62
|
```
|
63
63
|
|
@@ -66,11 +66,11 @@ Now, the middleware will only be used if a canonical host has been defined.
|
|
66
66
|
|
67
67
|
### Options
|
68
68
|
|
69
|
-
If you
|
70
|
-
option
|
69
|
+
If you’d like the middleware to ignore certain hosts, use the `:ignore`
|
70
|
+
option, which accepts a string, a regular expression, or an array of either.
|
71
71
|
|
72
|
-
```
|
73
|
-
use Rack::CanonicalHost, 'example.com', ignore:
|
72
|
+
```ruby
|
73
|
+
use Rack::CanonicalHost, 'example.com', ignore: 'api.example.com'
|
74
74
|
```
|
75
75
|
|
76
76
|
In this case, requests for the host `api.example.com` will not be redirected.
|
@@ -78,7 +78,7 @@ In this case, requests for the host `api.example.com` will not be redirected.
|
|
78
78
|
Alternatively, you can pass a block whose return value will be used as the
|
79
79
|
canonical host name.
|
80
80
|
|
81
|
-
```
|
81
|
+
```ruby
|
82
82
|
use Rack::CanonicalHost do |env|
|
83
83
|
case env['RACK_ENV'].to_sym
|
84
84
|
when :staging then 'staging.example.com'
|
@@ -87,10 +87,11 @@ use Rack::CanonicalHost do |env|
|
|
87
87
|
end
|
88
88
|
```
|
89
89
|
|
90
|
-
If you want it to react only on specific hosts
|
91
|
-
|
90
|
+
If you want it to react only on specific hosts within a multi-domain
|
91
|
+
environment, use the `:if` option, which accepts a string, a regular
|
92
|
+
expression, or an array of either.
|
92
93
|
|
93
|
-
```
|
94
|
+
```ruby
|
94
95
|
use Rack::CanonicalHost, 'example.com', if: /.*\.example\.com/
|
95
96
|
use Rack::CanonicalHost, 'example.ru', if: /.*\.example\.ru/
|
96
97
|
```
|
@@ -101,7 +102,7 @@ To avoid browsers indefinitely caching a `301` redirect, it’s a sensible idea
|
|
101
102
|
to set an expiry on each redirect, to hedge against the chance you may need to
|
102
103
|
change that redirect in the future.
|
103
104
|
|
104
|
-
```
|
105
|
+
```ruby
|
105
106
|
# Leave caching up to the browser (which could cache it indefinitely):
|
106
107
|
use Rack::CanonicalHost, 'example.com'
|
107
108
|
|
@@ -136,10 +137,11 @@ suggestions:
|
|
136
137
|
* [Nathaniel Bibler](https://github.com/nbibler)
|
137
138
|
* [Eric Allam](https://github.com/ericallam)
|
138
139
|
* [Fabrizio Regini](https://github.com/freegenie)
|
140
|
+
* [Daniel Searles](https://github.com/squaresurf)
|
139
141
|
|
140
142
|
|
141
143
|
## Copyright
|
142
144
|
|
143
|
-
Copyright © 2009-
|
145
|
+
Copyright © 2009-2017 Tyler Hunt.
|
144
146
|
|
145
147
|
Released under the terms of the MIT license. See LICENSE for details.
|
data/rack-canonical-host.gemspec
CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
|
10
10
|
gem.add_dependency 'addressable', '> 0', '< 3'
|
11
11
|
gem.add_dependency 'rack', ['>= 1.0.0', '< 3']
|
12
|
+
gem.add_development_dependency 'appraisal', '~> 2.2'
|
12
13
|
gem.add_development_dependency 'rake'
|
13
14
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
14
15
|
|
@@ -110,7 +110,7 @@ RSpec.describe Rack::CanonicalHost do
|
|
110
110
|
include_context 'a matching request'
|
111
111
|
end
|
112
112
|
|
113
|
-
context 'with :ignore option' do
|
113
|
+
context 'with :ignore string option' do
|
114
114
|
let(:app) { build_app('example.com', :ignore => 'example.net') }
|
115
115
|
|
116
116
|
include_context 'a matching request'
|
@@ -128,6 +128,24 @@ RSpec.describe Rack::CanonicalHost do
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
context 'with :ignore regex option' do
|
132
|
+
let(:app) { build_app('example.com', :ignore => /ex.*\.net/) }
|
133
|
+
|
134
|
+
include_context 'a matching request'
|
135
|
+
include_context 'a non-matching request'
|
136
|
+
|
137
|
+
context 'with a request to an ignored host' do
|
138
|
+
let(:url) { 'http://example.net/full/path' }
|
139
|
+
|
140
|
+
it { should_not be_redirect }
|
141
|
+
|
142
|
+
it 'calls the inner app' do
|
143
|
+
expect(inner_app).to receive(:call).with(env)
|
144
|
+
call_app
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
131
149
|
context 'with :if option' do
|
132
150
|
let(:app) { build_app('example.com', :if => 'www.example.net') }
|
133
151
|
|
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.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '3'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: appraisal
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.2'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.2'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: rake
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,11 +101,15 @@ files:
|
|
87
101
|
- ".gitignore"
|
88
102
|
- ".rspec"
|
89
103
|
- ".travis.yml"
|
104
|
+
- Appraisals
|
90
105
|
- CHANGELOG.md
|
91
106
|
- Gemfile
|
92
107
|
- LICENSE
|
93
108
|
- README.md
|
94
109
|
- Rakefile
|
110
|
+
- gemfiles/rack_1.5.gemfile
|
111
|
+
- gemfiles/rack_1.6.gemfile
|
112
|
+
- gemfiles/rack_2.0.gemfile
|
95
113
|
- lib/rack-canonical-host.rb
|
96
114
|
- lib/rack/canonical_host.rb
|
97
115
|
- lib/rack/canonical_host/redirect.rb
|
@@ -120,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
138
|
version: '0'
|
121
139
|
requirements: []
|
122
140
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.6.8
|
124
142
|
signing_key:
|
125
143
|
specification_version: 4
|
126
144
|
summary: Rack middleware for defining a canonical host name.
|