add valid_cookie? method to HTTP::Cookie
This commit is contained in:
parent
b67d20b157
commit
f0afbf2c5f
@ -131,7 +131,7 @@ module MechanizeCr
|
|||||||
host = uri.host
|
host = uri.host
|
||||||
valid_cookies = ::HTTP::Cookies.new
|
valid_cookies = ::HTTP::Cookies.new
|
||||||
request_cookies.each do |cookie|
|
request_cookies.each do |cookie|
|
||||||
valid_cookies << cookie if cookie.origin == host || (cookie.domain && host.try &.=~(/.*#{cookie.domain.try &.gsub(".", "\.")}$/))
|
valid_cookies << cookie if cookie.valid_cookie?(host)
|
||||||
end
|
end
|
||||||
valid_cookies
|
valid_cookies
|
||||||
end
|
end
|
||||||
@ -156,4 +156,12 @@ class HTTP::Cookie
|
|||||||
@value = value
|
@value = value
|
||||||
@origin = origin
|
@origin = origin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def valid_cookie?(host)
|
||||||
|
if domain
|
||||||
|
host.try &.=~(/.*#{domain.try &.gsub(".", "\.")}$/)
|
||||||
|
else
|
||||||
|
origin == host
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user