From d8f175a010e804808ea402b0937c0b3e29874438 Mon Sep 17 00:00:00 2001 From: Ben Hesseldieck Date: Fri, 15 Jan 2021 17:38:26 +0100 Subject: [PATCH] :hammer: improve handling of leading `/` --- packages/cli/src/ActiveWorkflowRunner.ts | 3 +-- packages/workflow/src/NodeHelpers.ts | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/ActiveWorkflowRunner.ts b/packages/cli/src/ActiveWorkflowRunner.ts index a6c3a321dc..e88d66019f 100644 --- a/packages/cli/src/ActiveWorkflowRunner.ts +++ b/packages/cli/src/ActiveWorkflowRunner.ts @@ -275,7 +275,7 @@ export class ActiveWorkflowRunner { webhook.webhookId = node.webhookId; } - if (webhook.webhookPath.charAt(0) === '/') { + if (webhook.webhookPath.startsWith('/')) { webhook.webhookPath = webhook.webhookPath.slice(1); } @@ -302,7 +302,6 @@ export class ActiveWorkflowRunner { // TODO check if there is standard error code for duplicate key violation that works // with all databases if (error.name === 'MongoError' || error.name === 'QueryFailedError') { - console.log(error); errorMessage = error.parameters.length === 5 ? `Node [${webhook.node}] can't be saved, please duplicate [${webhook.node}] and delete the currently existing one.` : `The webhook path [${webhook.webhookPath}] and method [${webhook.method}] already exist.`; diff --git a/packages/workflow/src/NodeHelpers.ts b/packages/workflow/src/NodeHelpers.ts index d10651e83b..afcfc334d7 100644 --- a/packages/workflow/src/NodeHelpers.ts +++ b/packages/workflow/src/NodeHelpers.ts @@ -893,6 +893,9 @@ export function getNodeWebhookUrl(baseUrl: string, workflowId: string, node: INo // setting this to false to prefix the webhookId isFullPath = false; } + if (path.startsWith('/')) { + path = path.slice(1); + } return `${baseUrl}/${getNodeWebhookPath(workflowId, node, path, isFullPath)}`; }