module WebAgent::CookieUtils
Public Instance Methods
domain_match(host, domain)
click to toggle source
# File lib/httpclient/webagent-cookie.rb, line 34 def domain_match(host, domain) return false if domain.nil? domainname = domain.sub(/\.\z/, '').downcase hostname = host.sub(/\.\z/, '').downcase case domain when /\d+\.\d+\.\d+\.\d+/ return (hostname == domainname) when '.' return true when /^\./ # allows; host == rubyforge.org, domain == .rubyforge.org return tail_match?(domainname, '.' + hostname) else return (hostname == domainname) end end
head_match?(str1, str2)
click to toggle source
# File lib/httpclient/webagent-cookie.rb, line 22 def head_match?(str1, str2) str1 == str2[0, str1.length] end
tail_match?(str1, str2)
click to toggle source
# File lib/httpclient/webagent-cookie.rb, line 26 def tail_match?(str1, str2) if str1.length > 0 str1 == str2[-str1.length..-1].to_s else true end end