Skip to content

Commit 47c00d2

Browse files
authored
Fix cookie parsing (#23)
1 parent 7ac961c commit 47c00d2

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/protocol/http/cookie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def to_s
6868
def self.parse(string)
6969
head, *directives = string.split(/\s*;\s*/)
7070

71-
key, value = head.split('=')
71+
key, value = head.split('=', 2)
7272
directives = self.parse_directives(directives)
7373

7474
self.new(

spec/protocol/http/header/cookie_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,15 @@
3636
expect(session.directives).to include('secure')
3737
end
3838
end
39+
40+
context "session=123==; secure" do
41+
it "has named cookie" do
42+
expect(cookies).to include('session')
43+
44+
session = cookies['session']
45+
expect(session).to have_attributes(name: 'session')
46+
expect(session).to have_attributes(value: '123==')
47+
expect(session.directives).to include('secure')
48+
end
49+
end
3950
end

0 commit comments

Comments
 (0)