@@ -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' , ( ) => {
@@ -797,6 +812,15 @@ describe('WebClient', () => {
797812 const client = new WebClient ( token , { allowAbsoluteUrls : false } ) ;
798813 await client . apiCall ( 'https://example.com/api/method' ) ;
799814 } ) ;
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 ( / a p i \/ m e t h o d / )
820+ . reply ( 200 , { ok : true } ) ;
821+ const client = new WebClient ( token , { slackApiUrl : alternativeUrl } ) ;
822+ await client . apiCall ( 'method' ) ;
823+ } ) ;
800824 } ) ;
801825
802826 describe ( 'has an option to set request concurrency' , ( ) => {
0 commit comments