rack-www 1.3.0 → 1.4.0
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.
- data/CHANGELOG.rdoc +6 -0
- data/lib/rack/www.rb +14 -4
- metadata +5 -5
data/CHANGELOG.rdoc
CHANGED
data/lib/rack/www.rb
CHANGED
@@ -19,13 +19,18 @@ module Rack
|
|
19
19
|
else
|
20
20
|
url = prepare_url(env)
|
21
21
|
headers = {"Content-Type" => "text/html", "location" => url}
|
22
|
-
|
22
|
+
if @message.respond_to?(:each)
|
23
|
+
message = @message
|
24
|
+
else
|
25
|
+
message = [@message || '']
|
26
|
+
end
|
27
|
+
[301, headers, message]
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
27
32
|
def already_subdomain?(env)
|
28
|
-
env["HTTP_HOST"].downcase =~ /^(#{@subdomain}.)/
|
33
|
+
env["HTTP_HOST"].downcase =~ /^(#{@subdomain}.)/
|
29
34
|
end
|
30
35
|
|
31
36
|
def prepare_url(env)
|
@@ -34,6 +39,12 @@ module Rack
|
|
34
39
|
host = env["SERVER_NAME"].gsub(/^(#{@subdomain}.)/, "")
|
35
40
|
host = host.gsub(/^(www.)/, "")
|
36
41
|
|
42
|
+
if env['SERVER_PORT'] == '80'
|
43
|
+
port = ''
|
44
|
+
else
|
45
|
+
port = ":#{env['SERVER_PORT']}"
|
46
|
+
end
|
47
|
+
|
37
48
|
path = env["PATH_INFO"]
|
38
49
|
|
39
50
|
query_string = ""
|
@@ -46,8 +57,7 @@ module Rack
|
|
46
57
|
else
|
47
58
|
host = "://" + host
|
48
59
|
end
|
49
|
-
scheme
|
60
|
+
"#{scheme}#{host}#{port}#{path}#{query_string}"
|
50
61
|
end
|
51
|
-
|
52
62
|
end
|
53
63
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-www
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jhimy Fernandes Villar
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-26 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
requirements: []
|
77
77
|
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.
|
79
|
+
rubygems_version: 1.6.2
|
80
80
|
signing_key:
|
81
81
|
specification_version: 3
|
82
82
|
summary: "Force redirects to a any given subdomain, e.g: www."
|