Skip to content

Commit 6dac498

Browse files
fix: add trailing slash to slackApiUrl if none is provided
1 parent 31c60f8 commit 6dac498

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

packages/web-api/src/WebClient.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ describe('WebClient', () => {
5858
const client = new WebClient();
5959
assert.instanceOf(client, WebClient);
6060
});
61+
62+
it('should add a trailing slash to slackApiUrl if missing', () => {
63+
const client = new WebClient(token, { slackApiUrl: 'https://slack.com/api' });
64+
assert.equal(client.slackApiUrl, 'https://slack.com/api/');
65+
});
66+
67+
it('should preserve trailing slash in slackApiUrl if provided', () => {
68+
const client = new WebClient(token, { slackApiUrl: 'https://slack.com/api/' });
69+
assert.equal(client.slackApiUrl, 'https://slack.com/api/');
70+
});
71+
72+
it('should handle custom domains and add trailing slash', () => {
73+
const client = new WebClient(token, { slackApiUrl: 'https://example.com/slack/api' });
74+
assert.equal(client.slackApiUrl, 'https://example.com/slack/api/');
75+
});
6176
});
6277

6378
describe('Methods superclass', () => {

packages/web-api/src/WebClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ export class WebClient extends Methods {
286286

287287
this.token = token;
288288
this.slackApiUrl = slackApiUrl;
289+
if (!this.slackApiUrl.endsWith('/')) {
290+
this.slackApiUrl += '/';
291+
}
289292

290293
this.retryConfig = retryConfig;
291294
this.requestQueue = new pQueue({ concurrency: maxRequestConcurrency });

0 commit comments

Comments
 (0)