diff options
Diffstat (limited to 'lib/rack/urlmap.rb')
-rw-r--r-- | lib/rack/urlmap.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/rack/urlmap.rb b/lib/rack/urlmap.rb index d301ce9b..df9e7d6d 100644 --- a/lib/rack/urlmap.rb +++ b/lib/rack/urlmap.rb @@ -48,9 +48,10 @@ module Rack sPort = env['SERVER_PORT'] @mapping.each do |host, location, match, app| - unless hHost == host \ - || sName == host \ - || (!host && (hHost == sName || hHost == sName+':'+sPort)) + unless casecmp?(hHost, host) \ + || casecmp?(sName, host) \ + || (!host && (casecmp?(hHost, sName) || + casecmp?(hHost, sName+':'+sPort))) next end @@ -71,6 +72,19 @@ module Rack env['PATH_INFO'] = path env['SCRIPT_NAME'] = script_name end + + private + def casecmp?(v1, v2) + # if both nil, or they're the same string + return true if v1 == v2 + + # if either are nil... (but they're not the same) + return false if v1.nil? + return false if v2.nil? + + # otherwise check they're not case-insensitive the same + v1.casecmp(v2).zero? + end end end |