From 25a386dd70df516090e622d921a79456fc7d16e3 Mon Sep 17 00:00:00 2001 From: Marcus <56945030+maspio@users.noreply.github.com> Date: Thu, 27 Apr 2023 11:42:37 +0200 Subject: [PATCH] fix(Mattermost Node): Fix base url trailing slash error (#6097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 Fix credential base url with trailing slash * Fix credential test base url with trailing slash --- packages/nodes-base/credentials/MattermostApi.credentials.ts | 2 +- packages/nodes-base/nodes/Mattermost/v1/transport/index.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nodes-base/credentials/MattermostApi.credentials.ts b/packages/nodes-base/credentials/MattermostApi.credentials.ts index afddc454fc..51a5d657ed 100644 --- a/packages/nodes-base/credentials/MattermostApi.credentials.ts +++ b/packages/nodes-base/credentials/MattermostApi.credentials.ts @@ -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}}', }, diff --git a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts index 53433954a1..d18d5e5967 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts @@ -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', },