Skip to content

Commit 343d049

Browse files
Add better test coverage and fix
1 parent 6dac498 commit 343d049

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,15 @@ describe('WebClient', () => {
812812
const client = new WebClient(token, { allowAbsoluteUrls: false });
813813
await client.apiCall('https://example.com/api/method');
814814
});
815+
816+
it('should add a trailing slash to slackApiUrl if missing', async () => {
817+
const alternativeUrl = 'http://12.34.56.78/api'; // No trailing slash here
818+
nock(alternativeUrl)
819+
.post(/api\/method/)
820+
.reply(200, { ok: true });
821+
const client = new WebClient(token, { slackApiUrl: alternativeUrl });
822+
await client.apiCall('method');
823+
});
815824
});
816825

817826
describe('has an option to set request concurrency', () => {

packages/web-api/src/WebClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export class WebClient extends Methods {
314314
this.axios = axios.create({
315315
adapter: adapter ? (config: InternalAxiosRequestConfig) => adapter({ ...config, adapter: undefined }) : undefined,
316316
timeout,
317-
baseURL: slackApiUrl,
317+
baseURL: this.slackApiUrl,
318318
headers: isElectron() ? headers : { 'User-Agent': getUserAgent(), ...headers },
319319
httpAgent: agent,
320320
httpsAgent: agent,

0 commit comments

Comments
 (0)