mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
cookie_hash.rb cleanup (#687)
This commit is contained in:
parent
b4aba417a5
commit
77cf459807
1 changed files with 6 additions and 6 deletions
|
@ -1,14 +1,14 @@
|
|||
class HTTParty::CookieHash < Hash #:nodoc:
|
||||
CLIENT_COOKIES = %w(path expires domain path secure httponly samesite)
|
||||
|
||||
def add_cookies(value)
|
||||
case value
|
||||
def add_cookies(data)
|
||||
case data
|
||||
when Hash
|
||||
merge!(value)
|
||||
merge!(data)
|
||||
when String
|
||||
value.split('; ').each do |cookie|
|
||||
array = cookie.split('=', 2)
|
||||
self[array[0].to_sym] = array[1] if array[0]
|
||||
data.split('; ').each do |cookie|
|
||||
key, value = cookie.split('=', 2)
|
||||
self[key.to_sym] = value if key
|
||||
end
|
||||
else
|
||||
raise "add_cookies only takes a Hash or a String"
|
||||
|
|
Loading…
Reference in a new issue