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:
|
class HTTParty::CookieHash < Hash #:nodoc:
|
||||||
CLIENT_COOKIES = %w(path expires domain path secure httponly samesite)
|
CLIENT_COOKIES = %w(path expires domain path secure httponly samesite)
|
||||||
|
|
||||||
def add_cookies(value)
|
def add_cookies(data)
|
||||||
case value
|
case data
|
||||||
when Hash
|
when Hash
|
||||||
merge!(value)
|
merge!(data)
|
||||||
when String
|
when String
|
||||||
value.split('; ').each do |cookie|
|
data.split('; ').each do |cookie|
|
||||||
array = cookie.split('=', 2)
|
key, value = cookie.split('=', 2)
|
||||||
self[array[0].to_sym] = array[1] if array[0]
|
self[key.to_sym] = value if key
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise "add_cookies only takes a Hash or a String"
|
raise "add_cookies only takes a Hash or a String"
|
||||||
|
|
Loading…
Reference in a new issue