From 2338f52e574d4b164e70a174dc2f8555cc2d748a Mon Sep 17 00:00:00 2001 From: the-laziest Date: Sun, 18 Aug 2024 06:43:30 +0200 Subject: [PATCH 1/2] Fix cookies get_dict --- curl_cffi/requests/cookies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curl_cffi/requests/cookies.py b/curl_cffi/requests/cookies.py index d24b253..3963e41 100644 --- a/curl_cffi/requests/cookies.py +++ b/curl_cffi/requests/cookies.py @@ -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 From b6bfd0606e77ec8a6f957a02fed8446d30150fe7 Mon Sep 17 00:00:00 2001 From: the-laziest Date: Sun, 18 Aug 2024 06:51:31 +0200 Subject: [PATCH 2/2] Tests added --- tests/unittest/test_cookies.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unittest/test_cookies.py b/tests/unittest/test_cookies.py index c24f115..2e50b1f 100644 --- a/tests/unittest/test_cookies.py +++ b/tests/unittest/test_cookies.py @@ -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"