From f880c68968404f82ef77690fdf937633e4fac325 Mon Sep 17 00:00:00 2001 From: Jonathan Nogueira Date: Wed, 13 Nov 2024 14:27:31 +0900 Subject: [PATCH] feat: Add preferences parameter to /searxng endpoint Added paramater and handles it in the query parameters. --- src/endpoints/search.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/endpoints/search.js b/src/endpoints/search.js index 6e21dfa5c..87152b3d6 100644 --- a/src/endpoints/search.js +++ b/src/endpoints/search.js @@ -160,7 +160,7 @@ router.post('/transcript', jsonParser, async (request, response) => { router.post('/searxng', jsonParser, async (request, response) => { try { - const { baseUrl, query } = request.body; + const { baseUrl, query, preferences } = request.body; if (!baseUrl || !query) { console.log('Missing required parameters for /searxng'); @@ -188,6 +188,9 @@ router.post('/searxng', jsonParser, async (request, response) => { const searchUrl = new URL('/search', baseUrl); const searchParams = new URLSearchParams(); searchParams.append('q', query); + if (preferences.length > 0) { + searchParams.append('preferences', preferences); + } searchUrl.search = searchParams.toString(); const searchResult = await fetch(searchUrl, { headers: visitHeaders });