🔨 improve handling of leading /

This commit is contained in:
Ben Hesseldieck 2021-01-15 17:38:26 +01:00
parent b3bf6f04b8
commit d8f175a010
2 changed files with 4 additions and 2 deletions

View file

@ -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.`;

View file

@ -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)}`;
}