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 +3 -0
- data/lib/rack/subdomain.rb +7 -3
- data/lib/rack/url.rb +6 -5
- data/lib/rewritten/version.rb +1 -1
- metadata +5 -5
data/HISTORY.rdoc
CHANGED
data/lib/rack/subdomain.rb
CHANGED
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
|
-
|
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
|
data/lib/rewritten/version.rb
CHANGED
metadata
CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
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-
|
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.
|
167
|
+
rubygems_version: 1.8.10
|
168
168
|
signing_key:
|
169
169
|
specification_version: 3
|
170
170
|
summary: A redis-based URL rewriting engine
|