Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix a bug where host matching occurs out of order

 * Closes #504
  • Loading branch information...
commit 60c66b5e087706b58aa5ff7072732c8ab8b8e7c1 1 parent e6b70a7
@raggi raggi authored
Showing with 3 additions and 2 deletions.
  1. +2 −1  lib/rack/urlmap.rb
  2. +1 −1  test/spec_urlmap.rb
View
3  lib/rack/urlmap.rb
@@ -13,6 +13,7 @@ module Rack
class URLMap
NEGATIVE_INFINITY = -1.0 / 0.0
+ INFINITY = 1.0 / 0.0
def initialize(map = {})
remap(map)
@@ -35,7 +36,7 @@ def remap(map)
[host, location, match, app]
}.sort_by do |(host, location, _, _)|
- [host ? -host.size : NEGATIVE_INFINITY, -location.size]
+ [host ? -host.size : INFINITY, -location.size]
end
end
View
2  test/spec_urlmap.rb
@@ -110,7 +110,7 @@
res = Rack::MockRequest.new(map).get("http://foo.org/")
res.should.be.ok
- res["X-Position"].should.equal "default.org"
+ res["X-Position"].should.equal "foo.org"
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org")
res.should.be.ok
Please sign in to comment.
Something went wrong with that request. Please try again.