class Capybara::Apparition::CookieJar
Public Class Methods
new(browser)
click to toggle source
# File lib/capybara/apparition/cookie_jar.rb, line 7 def initialize(browser) @browser = browser end
Public Instance Methods
[](name, domain = URI.parse(@browser.current_url).host, path = URI.parse(@browser.current_url).path)
Alias for: find
find(name, domain = URI.parse(@browser.current_url).host, path = URI.parse(@browser.current_url).path)
click to toggle source
def find(name, domain = nil, path = '/')
# File lib/capybara/apparition/cookie_jar.rb, line 12 def find(name, domain = URI.parse(@browser.current_url).host, path = URI.parse(@browser.current_url).path) # sort by path length because more specific take precendence cookies.sort_by { |c| -c.path.length }.find do |cookie| cookie.name.casecmp(name).zero? && (domain.nil? || match_domain?(cookie, domain)) && (path.nil? || match_path?(cookie, path)) end end
Also aliased as: []
Private Instance Methods
match_domain?(cookie, domain)
click to toggle source
# File lib/capybara/apparition/cookie_jar.rb, line 24 def match_domain?(cookie, domain) domain = '.' + domain cookie_domain = cookie.domain cookie_domain = '.' + cookie_domain unless cookie_domain.start_with?('.') # cookie_domain.downcase.end_with? domain.downcase domain.downcase.end_with? cookie_domain.downcase end
match_path?(cookie, path)
click to toggle source
# File lib/capybara/apparition/cookie_jar.rb, line 32 def match_path?(cookie, path) # cookie.path.start_with? path path.start_with? cookie.path end