Class: Greed::Cookie::PathHandler

Inherits:
Object
  • Object
show all
Includes:
Iterator
Defined in:
lib/greed/cookie/path_handler.rb

Instance Method Summary collapse

Instance Method Details

#determine_path(document_path, cookie_path) ⇒ Object

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/greed/cookie/path_handler.rb', line 16

def determine_path(document_path, cookie_path)
  return generate_default_path(document_path) if cookie_path.blank?
  # speed optimization for the common use case
  if cookie_path == ?/
    return {
      path: ?/,
    }
  end
  normalized_cookie_path = ::File.expand_path(?., cookie_path)
  iterate_cookie_path(document_path).each do |path_candidate|
    next unless path_candidate == normalized_cookie_path
    return {
      path: normalized_cookie_path,
    }
  end
  raise PathViolation
end