rack-host-redirect 1.1.1 → 1.1.2

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. checksums.yaml +4 -4
  2. data/lib/rack/host_redirect.rb +11 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c91524d1eaed816a11f75709f9213524b737fa6f
4
- data.tar.gz: f9f035700622a5003f4edeffa4363653b982369e
3
+ metadata.gz: cdbb38de454a694add16aba10f8c4518abbffd65
4
+ data.tar.gz: 3ccc2a649f0c8146b9b1eadce5554959f75b3bbc
5
5
  SHA512:
6
- metadata.gz: 71e278aae12ef9d2c001b39d3ea74b4a183ed5d27f95a9ef49ccdd29cd7e8d3ea0f718dee9a2de827a96d68af4f81be1246f51053686d2f3a930f467431a3778
7
- data.tar.gz: ebb913e93360a85218665044e898384eb1fa5355c0e4274bb4ce647af8068d02245f265090c4fff3d3a7d6f221f91b1c4b7cb38e67a7a496b3036ebfa97a7aa5
6
+ metadata.gz: 20be1733ff93683272a241f6191e95a1025a673daf2a0e9136036e61f7eebb6cb9e3c281c9e277e72a3805eaad4672b76f84f3e2a732bb76575831b2bc89540f
7
+ data.tar.gz: 55fb6747c589a71c8f2723ac5766c699fb9e05a0421873943c38fe0350ccaf3e27d6f4b1a018c203b81b01258beb952eb32018e2c27432b1684758edc09a9a61
@@ -1,5 +1,4 @@
1
- require 'rack'
2
- require 'uri'
1
+ require 'rack/request'
3
2
 
4
3
  class Rack::HostRedirect
5
4
 
@@ -29,9 +28,16 @@ class Rack::HostRedirect
29
28
  hsh.inject({}) {|out, (k, v)| out[k.downcase] = v; out }
30
29
  end
31
30
 
31
+ # Captures everything in url except the host:
32
+ #
33
+ # REPLACE_HOST_REGEX =~ 'https://foo.com/bar?baz=qux'
34
+ #
35
+ # $1 == 'https://'
36
+ # $2 == '/bar?baz=qux'
37
+ REPLACE_HOST_REGEX = /(https?:\/\/)[^\/\?:]+(.*)/
38
+
32
39
  def replace_host url, host
33
- url = URI.parse(url)
34
- url.host = host
35
- url.to_s
40
+ REPLACE_HOST_REGEX =~ url
41
+ "#{$1}#{host}#{$2}"
36
42
  end
37
43
  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.1
4
+ version: 1.1.2
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-21 00:00:00.000000000 Z
11
+ date: 2013-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack