Skip to content

Commit ff4fdd7

Browse files
committed
fix: normalizes boolean values in query parameters
Ensures boolean values are converted to lowercase strings ("true" or "false") when constructing query parameters. This prevents potential issues with case-sensitive APIs or services that expect specific boolean string representations.
1 parent 296d07b commit ff4fdd7

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "screenshotmax"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
description = "Official Python SDK for ScreenshotMAX API"
99
readme = "README.md"
1010
requires-python = ">=3.9"

src/screenshotmax/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def _sign_request(self, s: str) -> str:
1919
def _compute_query(self, obj: Dict[str, Any]) -> str:
2020
from urllib.parse import urlencode
2121

22-
filtered = {k: str(v) for k, v in obj.items() if v is not None}
22+
filtered = {
23+
k: (str(v).lower() if isinstance(v, bool) else str(v))
24+
for k, v in obj.items()
25+
if v is not None
26+
}
2327
return urlencode(filtered)
2428

2529
def generate_url(self, path: str, params: Optional[Dict[str, Any]] = None) -> str:

tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_generate_url_coerces_types(self):
5151
"/v1/test", {"delay": 2, "full_page": True}
5252
)
5353
self.assertIn("delay=2", result)
54-
self.assertIn("full_page=True", result)
54+
self.assertIn("full_page=true", result)
5555

5656
def test_generate_url_encodes_special_chars(self):
5757
result = self.client.generate_url("/v1/test", {"query": "a&b=c"})

0 commit comments

Comments
 (0)