./lib/rack/subdomain.rb in rack-subdomain-0.3.0 vs ./lib/rack/subdomain.rb in rack-subdomain-0.3.1

- old
+ new

@@ -1,9 +1,9 @@ +require 'ipaddress' + module Rack class Subdomain - VERSION = '0.3.0' - def initialize(app, domain, options = {}, &block) # Maintain compatibility with previous rack-subdomain gem options = {to: options} if options.is_a? String @options = {except: ['', 'www']}.merge(options) @@ -59,10 +59,10 @@ @domain end end def subdomain - @env['HTTP_HOST'].sub(/\.?#{domain}.*$/,'') unless @env['HTTP_HOST'].match(/^localhost/) + @env['HTTP_HOST'].sub(/\.?#{domain}.*$/,'') unless @env['HTTP_HOST'].match(/^localhost/) or IPAddress.valid?(@env['SERVER_NAME']) end def remap_with_substituted_path!(path) scheme = @env["rack.url_scheme"] host = "#{@subdomain}.#{domain}"