1
0
Fork 0
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:
Henrik Nyh 2020-02-20 07:57:39 +00:00 committed by GitHub
parent b4aba417a5
commit 77cf459807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"