lib/rack/subdomain.rb in rewritten-0.15.2 vs lib/rack/subdomain.rb in rewritten-0.16.0

- old
+ new

@@ -1,39 +1,31 @@ require 'rack' module Rack - module Rewritten - class Subdomain - def initialize(app, *fqdns) @app = app @fqdns = fqdns end def call(env) - puts "-> Rack::Rewritten::Subdomain" + puts '-> Rack::Rewritten::Subdomain' req = Rack::Request.new(env) @fqdns.each do |n| if req.host =~ /(.+)\.#{n}$/ - if $1 == 'www' + if Regexp.last_match(1) == 'www' break else - env["SUBDOMAIN"] = $1 - env["FQDN"] = n + env['SUBDOMAIN'] = Regexp.last_match(1) + env['FQDN'] = n break end end end - @app.call(env) + @app.call(env) end - end - end - end - -