Module: WebAgent::CookieUtils

Included in:
Cookie, CookieManager
Defined in:
lib/httpclient/cookie.rb

Instance Method Summary collapse

Instance Method Details

#domain_match(host, domain) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/httpclient/cookie.rb', line 32

def domain_match(host, domain)
  domain = domain.downcase
  host = host.downcase
  case domain
  when /\d+\.\d+\.\d+\.\d+/
	return (host == domain)
  when '.' 
	return true
  when /^\./
    # allows; host == rubyforge.org, domain == .rubyforge.org
	return tail_match?(domain, host) || (domain == '.' + host)
  else
	return (host == domain)
  end
end

#head_match?(str1, str2) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/httpclient/cookie.rb', line 20

def head_match?(str1, str2)
  str1 == str2[0, str1.length]
end

#tail_match?(str1, str2) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/httpclient/cookie.rb', line 24

def tail_match?(str1, str2)
  if str1.length > 0
	str1 == str2[-str1.length..-1].to_s
  else
	true
  end
end

#total_dot_num(string) ⇒ Object



48
49
50
# File 'lib/httpclient/cookie.rb', line 48

def total_dot_num(string)
  string.scan(/\./).length()
end