diff --git a/lib/puma/rack/urlmap.rb b/lib/puma/rack/urlmap.rb index a82c7ee8..adaf74a1 100644 --- a/lib/puma/rack/urlmap.rb +++ b/lib/puma/rack/urlmap.rb @@ -43,15 +43,17 @@ module Puma::Rack def call(env) path = env['PATH_INFO'] script_name = env['SCRIPT_NAME'] - hHost = env['HTTP_HOST'] - sName = env['SERVER_NAME'] - sPort = env['SERVER_PORT'] + http_host = env['HTTP_HOST'] + server_name = env['SERVER_NAME'] + server_port = env['SERVER_PORT'] + + is_same_server = casecmp?(http_host, server_name) || + casecmp?(http_host, "#{server_name}:#{server_port}") @mapping.each do |host, location, match, app| - unless casecmp?(hHost, host) \ - || casecmp?(sName, host) \ - || (!host && (casecmp?(hHost, sName) || - casecmp?(hHost, sName+':'+sPort))) + unless casecmp?(http_host, host) \ + || casecmp?(server_name, host) \ + || (!host && is_same_server) next end @@ -87,4 +89,3 @@ module Puma::Rack end end end -