From e0cbf4bf351e6cff9da0a367f68980dc4ba4ff1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 11 Jun 2026 16:32:19 +0400 Subject: [PATCH] fix: /export defaults to JSON, ?format=txt for plain text --- src/api/routes/entries.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/routes/entries.js b/src/api/routes/entries.js index dfa215c..43d3d8e 100644 --- a/src/api/routes/entries.js +++ b/src/api/routes/entries.js @@ -86,7 +86,7 @@ function createEntriesRouter({ q }) { }); // GET /api/v1/entries/export — агрегированный список CIDR - // ?format=json → JSON, иначе text/plain + // По умолчанию JSON. ?format=txt → text/plain. // Только для админа. router.get('/export', async (req, res) => { try { @@ -105,8 +105,8 @@ function createEntriesRouter({ q }) { const cidrs = await q.getExportCIDRs(companyId); const aggregated = aggregateCIDRs(cidrs); - const isJson = req.query.format === 'json'; - if (isJson) { + const isText = req.query.format === 'txt'; + if (!isText) { res.setHeader('Content-Type', 'application/json; charset=utf-8'); const fname = (req.query.filename || 'white-list.json').replace(/[^\w\-_. ]/g, '_'); const disp = req.query.view === '1' ? 'inline' : 'attachment';