File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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' , ( ) => {
Original file line number Diff line number Diff 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 } ) ;
You can’t perform that action at this time.
0 commit comments