lib/rack/urlmap.rb in rack-0.2.0 vs lib/rack/urlmap.rb in rack-0.3.0

- old
+ new

@@ -26,18 +26,16 @@ }.sort_by { |(h, l, a)| -l.size } # Longest path first end def call(env) path = env["PATH_INFO"].to_s.squeeze("/") + hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT') @mapping.each { |host, location, app| - if (env["HTTP_HOST"] == host || - env["SERVER_NAME"] == host || - (host == nil && (env["HTTP_HOST"] == env["SERVER_NAME"] || - env["HTTP_HOST"] == - "#{env["SERVER_NAME"]}:#{env["SERVER_PORT"]}"))) && - location == path[0, location.size] && (path[location.size] == nil || - path[location.size] == ?/) - env["SCRIPT_NAME"] = location.dup + if (hHost == host || sName == host \ + || (host.nil? && (hHost == sName || hHost == sName+':'+sPort))) \ + and location == path[0, location.size] \ + and (path[location.size] == nil || path[location.size] == ?/) + env["SCRIPT_NAME"] += location.dup env["PATH_INFO"] = path[location.size..-1] env["PATH_INFO"].gsub!(/\/\z/, '') env["PATH_INFO"] = "/" if env["PATH_INFO"].empty? return app.call(env) end