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.
Files changed (3) hide show
  1. data/CHANGELOG.rdoc +6 -0
  2. data/lib/rack/www.rb +14 -4
  3. metadata +5 -5
@@ -1,3 +1,9 @@
1
+ == 1.4
2
+
3
+ * Respect server port
4
+ * Body responds to :each
5
+ * Rack::Lint on tests
6
+
1
7
  == 1.3
2
8
 
3
9
  * Added possibility to redirects to any given :subdomain [Ryan Weald (https://github.com/rweald)].
@@ -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
- [301, headers, @message || ""]
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 + host + path + query_string
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: 27
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 1.3.0
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-05-25 00:00:00 -03:00
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.5.2
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."