File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -780,13 +780,19 @@ describe('WebClient', () => {
780780 await client . apiCall ( 'method' ) ;
781781 } ) ;
782782
783- it ( 'should send requests to an absolute URL' , async ( ) => {
783+ it ( 'should send requests to an absolute URL as default ' , async ( ) => {
784784 nock ( 'http://12.34.56.78/' ) . post ( '/api/method' ) . reply ( 200 , { ok : true } ) ;
785785 const client = new WebClient ( token ) ;
786786 await client . apiCall ( 'http://12.34.56.78/api/method' ) ;
787787 } ) ;
788788
789- it ( 'should send requests to the default URL' , async ( ) => {
789+ it ( 'should send requests to the absolute URL if absolute is allowed' , async ( ) => {
790+ nock ( 'https://example.com/' ) . post ( '/api/method' ) . reply ( 200 , { ok : true } ) ;
791+ const client = new WebClient ( token , { allowAbsoluteUrls : true } ) ;
792+ await client . apiCall ( 'https://example.com/api/method' ) ;
793+ } ) ;
794+
795+ it ( 'should send requests to the default URL if absolute not allowed' , async ( ) => {
790796 nock ( 'https://slack.com/' ) . post ( '/api/https://example.com/api/method' ) . reply ( 200 , { ok : true } ) ;
791797 const client = new WebClient ( token , { allowAbsoluteUrls : false } ) ;
792798 await client . apiCall ( 'https://example.com/api/method' ) ;
Original file line number Diff line number Diff line change @@ -744,7 +744,8 @@ export class WebClient extends Methods {
744744 * @param url - The resource to POST to. Either a Slack API method or absolute URL.
745745 */
746746 private deriveRequestUrl ( url : string ) : string {
747- if ( url . startsWith ( 'https' || 'http' ) && this . allowAbsoluteUrls ) {
747+ const isAbsoluteURL = url . startsWith ( 'https://' ) || url . startsWith ( 'http://' ) ;
748+ if ( isAbsoluteURL && this . allowAbsoluteUrls ) {
748749 return url ;
749750 }
750751 return `${ this . axios . getUri ( ) + url } ` ;
You can’t perform that action at this time.
0 commit comments