Module: WebAgent::CookieUtils

Included in:
Cookie, CookieManager
Defined in:
lib/reap/vendor/http-access2/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
# File 'lib/reap/vendor/http-access2/cookie.rb', line 32

def domain_match(host, domain)
  case domain
  when /\d+\.\d+\.\d+\.\d+/
    return (host == domain)
  when '.'
    return true
  when /^\./
    return tail_match?(domain, host)
  else
    return (host == domain)
  end
end

#head_match?(str1, str2) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/reap/vendor/http-access2/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/reap/vendor/http-access2/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



45
46
47
# File 'lib/reap/vendor/http-access2/cookie.rb', line 45

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