Skip to content

Instantly share code, notes, and snippets.

@he-and-her
Created April 16, 2017 03:33
Show Gist options
  • Save he-and-her/5bfbfc089eed4aba5e05b49893adc559 to your computer and use it in GitHub Desktop.
Save he-and-her/5bfbfc089eed4aba5e05b49893adc559 to your computer and use it in GitHub Desktop.
handle_options method from action_dispatch
def handle_options(options) #:nodoc:
options[:path] ||= "/"
if options[:domain] == :all || options[:domain] == "all"
domain_regexp = options[:tld_length] ? /([^.]+\.?){#{options[:tld_length]}}$/ : DOMAIN_REGEXP
options[:domain] = if (request.host !~ /^[\d.]+$/) && (request.host =~ domain_regexp)
".#{$&}"
end
elsif options[:domain].is_a? Array
options[:domain] = options[:domain].find { |domain| request.host.include? domain.sub(/^\./, "") }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment