rack-host-redirect 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack/host_redirect.rb +7 -6
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 367390cff2fac42a34e58511274cbdeec749d068
4
- data.tar.gz: c808f4eeeb7ad5731fd669fce8b83aa4bac628ce
3
+ metadata.gz: c91524d1eaed816a11f75709f9213524b737fa6f
4
+ data.tar.gz: f9f035700622a5003f4edeffa4363653b982369e
5
5
  SHA512:
6
- metadata.gz: 2eb330822e766d44c6ca64858cc67ebda97d073f71f8df6175a677f5117682ea9334c80087e63987bf0c1a63ba6bd18ab45641b8655a0ad8763c1184edbdaab6
7
- data.tar.gz: 15ea8109c47a94a2ad0f6b3bfeb63c1bf9ce9a6742b63360b34fe4057e55abe9ee909e8e6213c45e895b0d3f0f16da8596a343be90aaa0d96b5054b9631d5fc1
6
+ metadata.gz: 71e278aae12ef9d2c001b39d3ea74b4a183ed5d27f95a9ef49ccdd29cd7e8d3ea0f718dee9a2de827a96d68af4f81be1246f51053686d2f3a930f467431a3778
7
+ data.tar.gz: ebb913e93360a85218665044e898384eb1fa5355c0e4274bb4ce647af8068d02245f265090c4fff3d3a7d6f221f91b1c4b7cb38e67a7a496b3036ebfa97a7aa5
@@ -15,8 +15,9 @@ class Rack::HostRedirect
15
15
 
16
16
  updated_host = (@host_mapping && @host_mapping[host]) || (@block && @block.call(host, env))
17
17
 
18
- if updated_host
19
- redirect_to(updated_host, request)
18
+ if updated_host && updated_host.downcase != host
19
+ location = replace_host(request.url, updated_host)
20
+ [301, {'Location' => location}, []]
20
21
  else
21
22
  @app.call(env)
22
23
  end
@@ -28,9 +29,9 @@ class Rack::HostRedirect
28
29
  hsh.inject({}) {|out, (k, v)| out[k.downcase] = v; out }
29
30
  end
30
31
 
31
- def redirect_to updated_host, request
32
- location = URI.parse(request.url)
33
- location.host = updated_host
34
- [301, {'Location' => location.to_s}, []]
32
+ def replace_host url, host
33
+ url = URI.parse(url)
34
+ url.host = host
35
+ url.to_s
35
36
  end
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-host-redirect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Buesing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-10 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.0.0
69
+ rubygems_version: 2.0.2
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Lean and simple host redirection via Rack middleware