UNPKG

n8n

Version:

n8n Workflow Automation Tool

56 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WEBHOOK_TRIGGER_SCOPES = exports.FORM_TRIGGER_SCOPES = exports.WORKFLOW_MCP_TRIGGER_SCOPES = void 0; exports.trimTrailingSlash = trimTrailingSlash; exports.trimSlashes = trimSlashes; exports.resourceUrlToWebhookPath = resourceUrlToWebhookPath; exports.webhookResourcePath = webhookResourcePath; exports.methodQueryString = methodQueryString; exports.parseMethodParam = parseMethodParam; exports.WORKFLOW_MCP_TRIGGER_SCOPES = []; exports.FORM_TRIGGER_SCOPES = []; exports.WEBHOOK_TRIGGER_SCOPES = []; function trimTrailingSlash(path) { if (path.endsWith('/')) { path = path.slice(0, -1); } return path; } function trimSlashes(path) { if (path.startsWith('/')) { path = path.slice(1); } if (path.endsWith('/')) { path = path.slice(0, -1); } return path; } function resourceUrlToWebhookPath(resourceUrl, webhookBaseUrl) { let url; try { url = new URL(resourceUrl); } catch { return undefined; } const base = new URL(webhookBaseUrl); if (url.origin !== base.origin) { return undefined; } const basePath = trimTrailingSlash(base.pathname); if (basePath && !url.pathname.startsWith(`${basePath}/`)) { return undefined; } return url.pathname.slice(basePath.length); } function webhookResourcePath(webhookPath, webhookId) { return webhookId ? `${webhookId}/${webhookPath}` : webhookPath; } function methodQueryString(method) { return `?method=${method.toUpperCase()}`; } function parseMethodParam(value) { const method = value?.trim().toUpperCase(); return method === '' ? undefined : method; } //# sourceMappingURL=utils.js.map