From 99c027f96f6defe2d223632791fe7af8c4c1b6a8 Mon Sep 17 00:00:00 2001 From: shats Date: Tue, 3 Feb 2026 21:43:08 +0700 Subject: [PATCH] fix(mikrotikApplyService): filter routes by comment prefix when removing to ensure accurate route deletion --- backend/services/mikrotikApplyService.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/services/mikrotikApplyService.js b/backend/services/mikrotikApplyService.js index d745bab..ff0634d 100644 --- a/backend/services/mikrotikApplyService.js +++ b/backend/services/mikrotikApplyService.js @@ -270,8 +270,9 @@ async function applyOperation(client, op, dryRun) { if (path === '/ip/route') { if (action === 'remove' && meta?.findComment) { - const existing = await rosPrintWithQuery(client, '/ip/route', [`~comment=${meta.findComment}`]); - const toRemove = existing; + // REST API может игнорировать regex в .query и возвращать все маршруты — фильтруем на нашей стороне + const raw = await rosPrintWithQuery(client, '/ip/route', [`~comment=${meta.findComment}`]); + const toRemove = raw.filter(r => (r.comment || '').startsWith('Recursive: ')); if (toRemove.length === 0) { result.status = 'skip'; result.details = 'No matching routes to remove';