Skip to content

Commit

Permalink
store parsed cookie attributes as symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
stve committed Apr 13, 2016
1 parent e69dc4d commit b291397
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/secure_headers/headers/cookie.rb
Expand Up @@ -79,9 +79,9 @@ def initialize(cookie, config)
@raw_cookie = cookie
@config = config
@attributes = {
"secure" => nil,
"httponly" => nil,
"samesite" => nil,
httponly: nil,
samesite: nil,
secure: nil,
}

parse(cookie)
Expand Down Expand Up @@ -114,7 +114,7 @@ def parsed_cookie
end

def already_flagged?(attribute)
@attributes[attribute.to_s]
@attributes[attribute]
end

def flag_cookie?(attribute)
Expand Down Expand Up @@ -178,8 +178,9 @@ def parse(cookie)
name, values = pairs.split('=',2)
name = CGI.unescape(name)

if @attributes.has_key?(name.downcase)
@attributes[name.downcase] = values || true
attribute = name.downcase.to_sym
if @attributes.has_key?(attribute)
@attributes[attribute] = values || true
end
end
end
Expand Down

0 comments on commit b291397

Please sign in to comment.