fix(Mattermost Node): Fix base url trailing slash error (#6097)

* 🐛 Fix credential base url with trailing slash

* Fix credential test base url with trailing slash
This commit is contained in:
Marcus 2023-04-27 11:42:37 +02:00 committed by GitHub
parent c65ac03368
commit 25a386dd70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -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}}',
},

View file

@ -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',
},