Skip to content

Commit c5107a7

Browse files
committed
improving tests and _get_url()
1 parent ced7e01 commit c5107a7

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

slack_sdk/web/internal_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def _get_url(base_url: str, api_method: str) -> str:
6767
The absolute API URL.
6868
e.g. 'https://slack.com/api/chat.postMessage'
6969
"""
70-
if base_url.endswith("/") and api_method.startswith("/"):
71-
api_method = api_method.lstrip("/")
70+
# Ensure no leading slash in api_method to prevent double slashes
71+
api_method = api_method.lstrip("/")
7272
return urljoin(base_url, api_method)
7373

7474

tests/slack_sdk/web/test_internal_utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ def test_get_url_prevent_double_slash(self):
119119
"Should correctly handle and remove double slashes between base_url and api_method",
120120
)
121121

122-
# Test case: Handle base_url without trailing slash
123-
api_url = _get_url("https://slack.com/api", "chat.postMessage")
124-
self.assertEqual(
125-
api_url,
126-
"https://slack.com/chat.postMessage",
127-
"Should correctly handle base_url without a trailing slash",
128-
)
129-
130122
# Test case: Handle api_method without leading slash
131123
api_url = _get_url("https://slack.com/api/", "chat.postMessage")
132124
self.assertEqual(
@@ -136,9 +128,9 @@ def test_get_url_prevent_double_slash(self):
136128
)
137129

138130
# Test case: Both inputs are clean
139-
api_url = _get_url("https://slack.com/api", "/chat.postMessage")
131+
api_url = _get_url("https://slack.com/api/", "chat.postMessage")
140132
self.assertEqual(
141133
api_url,
142-
"https://slack.com/chat.postMessage",
134+
"https://slack.com/api/chat.postMessage",
143135
"Should correctly combine base_url and api_method with clean inputs",
144136
)

0 commit comments

Comments
 (0)