rewritten 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.3.0
2
+
3
+ * support for forwarded request staying on the forwarding host
1
4
 
2
5
  == 0.2.1
3
6
 
@@ -17,9 +17,13 @@ module Rack
17
17
 
18
18
  @fqdns.each do |n|
19
19
  if req.host =~ /(.+)\.#{n}$/
20
- env["SUBDOMAIN"] = $1
21
- env["FQDN"] = n
22
- break
20
+ if $1 == 'www'
21
+ break
22
+ else
23
+ env["SUBDOMAIN"] = $1
24
+ env["FQDN"] = n
25
+ break
26
+ end
23
27
  end
24
28
  end
25
29
 
data/lib/rack/url.rb CHANGED
@@ -11,13 +11,10 @@ module Rack
11
11
  end
12
12
 
13
13
  def call(env)
14
- puts "-> Rack::Rewritten::Url"
15
14
  req = Rack::Request.new(env)
16
15
 
17
16
  subdomain = env["SUBDOMAIN"] ? "#{env["SUBDOMAIN"]}:" : ""
18
17
 
19
- puts "SUBDOMAIN: #{subdomain}"
20
-
21
18
  if to = ::Rewritten.redis.get("from:#{subdomain}#{req.path_info}")
22
19
  current_path = ::Rewritten.list_range("to:#{to}", -1, 1)
23
20
  current_path = current_path.split(":").last
@@ -34,12 +31,16 @@ module Rack
34
31
 
35
32
  new_path = env["rack.url_scheme"].dup
36
33
  new_path << "://"
37
- new_path << env["HTTP_HOST"].dup.sub(/^#{subdomain.chomp(':')}\./, '')
34
+ if env["HTTP_X_FORWARDED_HOST"]
35
+ new_path << env["HTTP_X_FORWARDED_HOST"].dup.sub(/^#{subdomain.chomp(':')}\./, '')
36
+ else
37
+ new_path << env["HTTP_HOST"].dup.sub(/^#{subdomain.chomp(':')}\./, '')
38
+ end
38
39
  new_path << current_path
39
40
 
40
41
  r.redirect(new_path, 301)
41
42
  a = r.finish
42
- puts a.inspect
43
+ #puts a.inspect
43
44
  a
44
45
  end
45
46
  else
@@ -1,3 +1,3 @@
1
1
  module Rewritten
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kai Rubarth
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-27 00:00:00 Z
18
+ date: 2011-12-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: redis-namespace
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  requirements: []
165
165
 
166
166
  rubyforge_project: rewritten
167
- rubygems_version: 1.8.6
167
+ rubygems_version: 1.8.10
168
168
  signing_key:
169
169
  specification_version: 3
170
170
  summary: A redis-based URL rewriting engine