Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cookies get_dict #372

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion curl_cffi/requests/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def get_dict(self, domain: Optional[str] = None, path: Optional[str] = None) ->
"""
ret = {}
for cookie in self.jar:
if (domain is None or cookie.name == domain) and (path is None or cookie.path == path):
if (domain is None or cookie.domain == domain) and (path is None or cookie.path == path):
ret[cookie.name] = cookie.value
return ret

Expand Down
12 changes: 12 additions & 0 deletions tests/unittest/test_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@ def test_get_dict():
assert d["foo"] == "bar"
assert d["hello"] == "world"
assert d["a"] == "b"

c = Cookies()
c.set("foo", "bar", domain="example.com")
c.set("hello", "world", domain="example.com")
c.set("foo", "bar", domain="test.local")
d_example = c.get_dict("example.com")
d_test = c.get_dict("test.local")
assert len(d_example) == 2
assert d_example["foo"] == "bar"
assert d_example["hello"] == "world"
assert len(d_test) == 1
assert d_test["foo"] == "bar"
Loading