rack-rewrite 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-rewrite (1.1.0)
4
+ rack-rewrite (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/History.rdoc CHANGED
@@ -1,4 +1,8 @@
1
- === 1.2.0 / 2011-09--20
1
+ === 1.2.1 / 2011-09-20
2
+ * Maintenance
3
+ * Use Rack::Request to match the host
4
+
5
+ === 1.2.0 / 2011-09-20
2
6
  * API
3
7
  * :headers option to send additional headers with the response
4
8
 
data/README.rdoc CHANGED
@@ -13,7 +13,7 @@ can get away with rack-rewrite instead of writing Apache mod_rewrite rules.
13
13
 
14
14
  === Sample rackup file
15
15
 
16
- gem 'rack-rewrite', '~> 1.2.0'
16
+ gem 'rack-rewrite', '~> 1.2.1'
17
17
  require 'rack/rewrite'
18
18
  use Rack::Rewrite do
19
19
  rewrite '/wiki/John_Trupiano', '/john'
@@ -23,8 +23,7 @@ can get away with rack-rewrite instead of writing Apache mod_rewrite rules.
23
23
  end
24
24
 
25
25
  === Sample usage in a rails app
26
- config.gem 'rack-rewrite', '~> 1.2.0'
27
- require 'rack/rewrite'
26
+
28
27
  config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
29
28
  rewrite '/wiki/John_Trupiano', '/john'
30
29
  r301 '/wiki/Yair_Flicker', '/yair'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.2.1
@@ -128,13 +128,14 @@ module Rack
128
128
 
129
129
  def match_options?(env, path = build_path_from_env(env))
130
130
  matches = []
131
-
131
+ request = Rack::Request.new(env)
132
+
132
133
  # negative matches
133
134
  matches << !string_matches?(path, options[:not]) if options[:not]
134
135
 
135
136
  # possitive matches
136
137
  matches << string_matches?(env['REQUEST_METHOD'], options[:method]) if options[:method]
137
- matches << string_matches?(env['SERVER_NAME'], options[:host]) if options[:host]
138
+ matches << string_matches?(request.host, options[:host]) if options[:host]
138
139
 
139
140
  matches.all?
140
141
  end
data/test/rule_test.rb CHANGED
@@ -180,11 +180,19 @@ class RuleTest < Test::Unit::TestCase
180
180
  end
181
181
 
182
182
  should 'match PATH_INFO of /features and HOST of testapp.com' do
183
- assert @rule.matches?(rack_env_for("/features", 'SERVER_NAME' => 'testapp.com'))
183
+ assert @rule.matches?(rack_env_for("/features", 'SERVER_NAME' => 'testapp.com', "SERVER_PORT" => "8080"))
184
184
  end
185
185
 
186
186
  should 'not match PATH_INFO of /features and HOST of nottestapp.com' do
187
- assert ! @rule.matches?(rack_env_for("/features", 'SERVER_NAME' => 'nottestapp.com'))
187
+ assert ! @rule.matches?(rack_env_for("/features", 'SERVER_NAME' => 'nottestapp.com', "SERVER_PORT" => "8080"))
188
+ end
189
+
190
+ should 'match PATH_INFO of /features AND HTTP_X_FORWARDED_HOST of testapp.com and SERVER_NAME of 127.0.0.1' do
191
+ assert @rule.matches?(rack_env_for("/features", "SERVER_NAME" => "127.0.0.1", "SERVER_PORT" => "8080", "HTTP_X_FORWARDED_HOST" => "testapp.com"))
192
+ end
193
+
194
+ should 'not match PATH_INFO of /features AND HTTP_X_FORWARDED_HOST of nottestapp.com and SERVER_NAME of 127.0.0.1' do
195
+ assert !@rule.matches?(rack_env_for("/features", "SERVER_NAME" => "127.0.0.1", "SERVER_PORT" => "8080", "HTTP_X_FORWARDED_HOST" => "nottestapp.com"))
188
196
  end
189
197
  end
190
198
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-rewrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
- requirement: &2156177220 !ruby/object:Gem::Requirement
17
+ requirement: &2153125460 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 1.0.10
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2156177220
25
+ version_requirements: *2153125460
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: shoulda
28
- requirement: &2156176760 !ruby/object:Gem::Requirement
28
+ requirement: &2153125000 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.10.2
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2156176760
36
+ version_requirements: *2153125000
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: mocha
39
- requirement: &2156200620 !ruby/object:Gem::Requirement
39
+ requirement: &2153148840 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.9.7
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2156200620
47
+ version_requirements: *2153148840
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rack
50
- requirement: &2156200240 !ruby/object:Gem::Requirement
50
+ requirement: &2153148460 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2156200240
58
+ version_requirements: *2153148460
59
59
  description: A rack middleware for enforcing rewrite rules. In many cases you can
60
60
  get away with rack-rewrite instead of writing Apache mod_rewrite rules.
61
61
  email: jtrupiano@gmail.com