Skip to content
This repository
Browse code

Fix a bug where host matching occurs out of order

 * Closes #504
  • Loading branch information...
commit 60c66b5e087706b58aa5ff7072732c8ab8b8e7c1 1 parent e6b70a7
James Tucker authored February 06, 2013
3  lib/rack/urlmap.rb
@@ -13,6 +13,7 @@ module Rack
13 13
 
14 14
   class URLMap
15 15
     NEGATIVE_INFINITY = -1.0 / 0.0
  16
+    INFINITY = 1.0 / 0.0
16 17
 
17 18
     def initialize(map = {})
18 19
       remap(map)
@@ -35,7 +36,7 @@ def remap(map)
35 36
 
36 37
         [host, location, match, app]
37 38
       }.sort_by do |(host, location, _, _)|
38  
-        [host ? -host.size : NEGATIVE_INFINITY, -location.size]
  39
+        [host ? -host.size : INFINITY, -location.size]
39 40
       end
40 41
     end
41 42
 
2  test/spec_urlmap.rb
@@ -110,7 +110,7 @@
110 110
 
111 111
     res = Rack::MockRequest.new(map).get("http://foo.org/")
112 112
     res.should.be.ok
113  
-    res["X-Position"].should.equal "default.org"
  113
+    res["X-Position"].should.equal "foo.org"
114 114
 
115 115
     res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org")
116 116
     res.should.be.ok

0 notes on commit 60c66b5

Please sign in to comment.
Something went wrong with that request. Please try again.