Skip to content

Commit b291397

Browse files
committed
store parsed cookie attributes as symbols
1 parent e69dc4d commit b291397

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/secure_headers/headers/cookie.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ def initialize(cookie, config)
7979
@raw_cookie = cookie
8080
@config = config
8181
@attributes = {
82-
"secure" => nil,
83-
"httponly" => nil,
84-
"samesite" => nil,
82+
httponly: nil,
83+
samesite: nil,
84+
secure: nil,
8585
}
8686

8787
parse(cookie)
@@ -114,7 +114,7 @@ def parsed_cookie
114114
end
115115

116116
def already_flagged?(attribute)
117-
@attributes[attribute.to_s]
117+
@attributes[attribute]
118118
end
119119

120120
def flag_cookie?(attribute)
@@ -178,8 +178,9 @@ def parse(cookie)
178178
name, values = pairs.split('=',2)
179179
name = CGI.unescape(name)
180180

181-
if @attributes.has_key?(name.downcase)
182-
@attributes[name.downcase] = values || true
181+
attribute = name.downcase.to_sym
182+
if @attributes.has_key?(attribute)
183+
@attributes[attribute] = values || true
183184
end
184185
end
185186
end

0 commit comments

Comments
 (0)