mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make handle_options
method private
`handle_options` method in `CookieJar` is used internal only, so it should be private.
This commit is contained in:
parent
aa7da0471f
commit
7a59b9f1a0
1 changed files with 22 additions and 22 deletions
|
@ -347,28 +347,6 @@ module ActionDispatch
|
|||
@cookies.map { |k, v| "#{escape(k)}=#{escape(v)}" }.join "; "
|
||||
end
|
||||
|
||||
def handle_options(options) # :nodoc:
|
||||
if options[:expires].respond_to?(:from_now)
|
||||
options[:expires] = options[:expires].from_now
|
||||
end
|
||||
|
||||
options[:path] ||= "/"
|
||||
|
||||
if options[:domain] == :all || options[:domain] == "all"
|
||||
# If there is a provided tld length then we use it otherwise default domain regexp.
|
||||
domain_regexp = options[:tld_length] ? /([^.]+\.?){#{options[:tld_length]}}$/ : DOMAIN_REGEXP
|
||||
|
||||
# If host is not ip and matches domain regexp.
|
||||
# (ip confirms to domain regexp so we explicitly check for ip)
|
||||
options[:domain] = if (request.host !~ /^[\d.]+$/) && (request.host =~ domain_regexp)
|
||||
".#{$&}"
|
||||
end
|
||||
elsif options[:domain].is_a? Array
|
||||
# If host matches one of the supplied domains without a dot in front of it.
|
||||
options[:domain] = options[:domain].find { |domain| request.host.include? domain.sub(/^\./, "") }
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the cookie named +name+. The second argument may be the cookie's
|
||||
# value or a hash of options as documented above.
|
||||
def []=(name, options)
|
||||
|
@ -449,6 +427,28 @@ module ActionDispatch
|
|||
def write_cookie?(cookie)
|
||||
request.ssl? || !cookie[:secure] || always_write_cookie
|
||||
end
|
||||
|
||||
def handle_options(options)
|
||||
if options[:expires].respond_to?(:from_now)
|
||||
options[:expires] = options[:expires].from_now
|
||||
end
|
||||
|
||||
options[:path] ||= "/"
|
||||
|
||||
if options[:domain] == :all || options[:domain] == "all"
|
||||
# If there is a provided tld length then we use it otherwise default domain regexp.
|
||||
domain_regexp = options[:tld_length] ? /([^.]+\.?){#{options[:tld_length]}}$/ : DOMAIN_REGEXP
|
||||
|
||||
# If host is not ip and matches domain regexp.
|
||||
# (ip confirms to domain regexp so we explicitly check for ip)
|
||||
options[:domain] = if (request.host !~ /^[\d.]+$/) && (request.host =~ domain_regexp)
|
||||
".#{$&}"
|
||||
end
|
||||
elsif options[:domain].is_a? Array
|
||||
# If host matches one of the supplied domains without a dot in front of it.
|
||||
options[:domain] = options[:domain].find { |domain| request.host.include? domain.sub(/^\./, "") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class AbstractCookieJar # :nodoc:
|
||||
|
|
Loading…
Reference in a new issue