[fix] plugins: bugfix of tor_check and unit_converter

Closes: https://github.com/searxng/searxng/issues/4461
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2025-03-07 17:35:26 +01:00 committed by Markus Heiser
parent f49b2c94a9
commit da7b069d6e
3 changed files with 19 additions and 19 deletions

View file

@ -25,7 +25,7 @@ import babel.numbers
from flask_babel import gettext, get_locale
from searx import data
from searx.result_types import Answer
from searx.result_types import EngineResults
name = "Unit converter plugin"
@ -245,8 +245,8 @@ def _parse_text_and_convert(from_query, to_query) -> str | None:
return f'{result} {target_symbol}'
def post_search(_request, search) -> list[Answer]:
results = []
def post_search(_request, search) -> EngineResults:
results = EngineResults()
# only convert between units on the first page
if search.search_query.pageno > 1:
@ -264,6 +264,6 @@ def post_search(_request, search) -> list[Answer]:
from_query, to_query = query.split(keyword, 1)
target_val = _parse_text_and_convert(from_query.strip(), to_query.strip())
if target_val:
Answer(results=results, answer=target_val)
results.add(results.types.Answer(answer=target_val))
return results