From 98f02317ccd5de80ecab3b7976e766cdea78ae80 Mon Sep 17 00:00:00 2001 From: Henrique Date: Mon, 18 Nov 2024 21:03:08 -0500 Subject: [PATCH 1/3] add trailing slash to the end of the url --- slack_sdk/web/async_base_client.py | 3 +++ slack_sdk/web/base_client.py | 3 +++ tests/slack_sdk/web/test_web_client.py | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/slack_sdk/web/async_base_client.py b/slack_sdk/web/async_base_client.py index 2418b08c..9b03b819 100644 --- a/slack_sdk/web/async_base_client.py +++ b/slack_sdk/web/async_base_client.py @@ -46,6 +46,9 @@ def __init__( ): self.token = None if token is None else token.strip() """A string specifying an `xoxp-*` or `xoxb-*` token.""" + # self.base_url = base_url + if not base_url.endswith("/"): + base_url += "/" self.base_url = base_url """A string representing the Slack API base URL. Default is `'https://slack.com/api/'`.""" diff --git a/slack_sdk/web/base_client.py b/slack_sdk/web/base_client.py index e112d35c..855d0fa5 100644 --- a/slack_sdk/web/base_client.py +++ b/slack_sdk/web/base_client.py @@ -59,6 +59,9 @@ def __init__( ): self.token = None if token is None else token.strip() """A string specifying an `xoxp-*` or `xoxb-*` token.""" + # self.base_url = base_url + if not base_url.endswith("/"): + base_url += "/" self.base_url = base_url """A string representing the Slack API base URL. Default is `'https://slack.com/api/'`.""" diff --git a/tests/slack_sdk/web/test_web_client.py b/tests/slack_sdk/web/test_web_client.py index 024915a2..e6c6697c 100644 --- a/tests/slack_sdk/web/test_web_client.py +++ b/tests/slack_sdk/web/test_web_client.py @@ -229,3 +229,11 @@ def test_user_auth_blocks(self): user_auth_blocks=[DividerBlock(), DividerBlock()], ) self.assertIsNone(new_message.get("error")) + + def test_base_url_appends_trailing_slash_issue_15141(self): + client = self.client + self.assertEqual(client.base_url, "http://localhost:8888/") + + def test_base_url_preserves_trailing_slash_issue_15141(self): + client = WebClient(base_url="http://localhost:8888/") + self.assertEqual(client.base_url, "http://localhost:8888/") From 169283b510d82bc544f3ff3ed36fe3fb444cd435 Mon Sep 17 00:00:00 2001 From: Henrique Date: Tue, 19 Nov 2024 08:23:03 -0500 Subject: [PATCH 2/3] removing commented lines --- slack_sdk/web/async_base_client.py | 1 - slack_sdk/web/base_client.py | 1 - 2 files changed, 2 deletions(-) diff --git a/slack_sdk/web/async_base_client.py b/slack_sdk/web/async_base_client.py index 9b03b819..65f852b6 100644 --- a/slack_sdk/web/async_base_client.py +++ b/slack_sdk/web/async_base_client.py @@ -46,7 +46,6 @@ def __init__( ): self.token = None if token is None else token.strip() """A string specifying an `xoxp-*` or `xoxb-*` token.""" - # self.base_url = base_url if not base_url.endswith("/"): base_url += "/" self.base_url = base_url diff --git a/slack_sdk/web/base_client.py b/slack_sdk/web/base_client.py index 855d0fa5..4ce67b0c 100644 --- a/slack_sdk/web/base_client.py +++ b/slack_sdk/web/base_client.py @@ -59,7 +59,6 @@ def __init__( ): self.token = None if token is None else token.strip() """A string specifying an `xoxp-*` or `xoxb-*` token.""" - # self.base_url = base_url if not base_url.endswith("/"): base_url += "/" self.base_url = base_url From b62e6087fb2606b04cd9264bb73554630ee07f98 Mon Sep 17 00:00:00 2001 From: Henrique Date: Tue, 19 Nov 2024 08:24:38 -0500 Subject: [PATCH 3/3] adding trailing slash to legacy_base_client.py --- slack_sdk/web/legacy_base_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/slack_sdk/web/legacy_base_client.py b/slack_sdk/web/legacy_base_client.py index c58e062a..44d49970 100644 --- a/slack_sdk/web/legacy_base_client.py +++ b/slack_sdk/web/legacy_base_client.py @@ -62,6 +62,8 @@ def __init__( ): self.token = None if token is None else token.strip() """A string specifying an `xoxp-*` or `xoxb-*` token.""" + if not base_url.endswith("/"): + base_url += "/" self.base_url = base_url """A string representing the Slack API base URL. Default is `'https://slack.com/api/'`."""