Skip to content

Commit c82c9a0

Browse files
HTSagaraseratch
andauthored
add trailing slash to the end of the url (#1594)
* add trailing slash to the end of the url * removing commented lines * adding trailing slash to legacy_base_client.py --------- Co-authored-by: Kazuhiro Sera <[email protected]>
1 parent d1dffb7 commit c82c9a0

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

slack_sdk/web/async_base_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def __init__(
4646
):
4747
self.token = None if token is None else token.strip()
4848
"""A string specifying an `xoxp-*` or `xoxb-*` token."""
49+
if not base_url.endswith("/"):
50+
base_url += "/"
4951
self.base_url = base_url
5052
"""A string representing the Slack API base URL.
5153
Default is `'https://slack.com/api/'`."""

slack_sdk/web/base_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(
5959
):
6060
self.token = None if token is None else token.strip()
6161
"""A string specifying an `xoxp-*` or `xoxb-*` token."""
62+
if not base_url.endswith("/"):
63+
base_url += "/"
6264
self.base_url = base_url
6365
"""A string representing the Slack API base URL.
6466
Default is `'https://slack.com/api/'`."""

slack_sdk/web/legacy_base_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def __init__(
6262
):
6363
self.token = None if token is None else token.strip()
6464
"""A string specifying an `xoxp-*` or `xoxb-*` token."""
65+
if not base_url.endswith("/"):
66+
base_url += "/"
6567
self.base_url = base_url
6668
"""A string representing the Slack API base URL.
6769
Default is `'https://slack.com/api/'`."""

tests/slack_sdk/web/test_web_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,11 @@ def test_user_auth_blocks(self):
229229
user_auth_blocks=[DividerBlock(), DividerBlock()],
230230
)
231231
self.assertIsNone(new_message.get("error"))
232+
233+
def test_base_url_appends_trailing_slash_issue_15141(self):
234+
client = self.client
235+
self.assertEqual(client.base_url, "http://localhost:8888/")
236+
237+
def test_base_url_preserves_trailing_slash_issue_15141(self):
238+
client = WebClient(base_url="http://localhost:8888/")
239+
self.assertEqual(client.base_url, "http://localhost:8888/")

0 commit comments

Comments
 (0)