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
|
||||
valid_cookies = ::HTTP::Cookies.new
|
||||
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
|
||||
valid_cookies
|
||||
end
|
||||
@ -156,4 +156,12 @@ class HTTP::Cookie
|
||||
@value = value
|
||||
@origin = origin
|
||||
end
|
||||
|
||||
def valid_cookie?(host)
|
||||
if domain
|
||||
host.try &.=~(/.*#{domain.try &.gsub(".", "\.")}$/)
|
||||
else
|
||||
origin == host
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user