Skip to content

Commit

Permalink
fix(Mattermost Node): Fix base url trailing slash error (#6097)
Browse files Browse the repository at this point in the history
* 馃悰 Fix credential base url with trailing slash

* Fix credential test base url with trailing slash
  • Loading branch information
maspio authored and netroy committed May 2, 2023
1 parent 4f56194 commit 788fda1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class MattermostApi implements ICredentialType {

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl}}/api/v4',
baseURL: '={{$credentials.baseUrl.replace(/\\/$/, "")}}/api/v4',
url: '/users',
skipSslCertificateValidation: '={{$credentials?.allowUnauthorizedCerts}}',
},
Expand Down
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/Mattermost/v1/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export async function apiRequest(
query: IDataObject = {},
) {
const credentials = await this.getCredentials('mattermostApi');
const baseUrl = (credentials.baseUrl as string).replace(/\/$/, '');

const options: IHttpRequestOptions = {
method,
body,
qs: query,
url: `${credentials.baseUrl}/api/v4/${endpoint}`,
url: `${baseUrl}/api/v4/${endpoint}`,
headers: {
'content-type': 'application/json; charset=utf-8',
},
Expand Down

0 comments on commit 788fda1

Please sign in to comment.