n8n
Version:
n8n Workflow Automation Tool
41 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WORKFLOW_MCP_TRIGGER_SCOPES = void 0;
exports.trimTrailingSlash = trimTrailingSlash;
exports.trimSlashes = trimSlashes;
exports.resourceUrlToWebhookPath = resourceUrlToWebhookPath;
exports.WORKFLOW_MCP_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);
}
//# sourceMappingURL=utils.js.map