From a8791deb13156c932f2a17856365ccd39313e823 Mon Sep 17 00:00:00 2001 From: neon_arch Date: Sun, 30 Jul 2023 20:14:40 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix:=20add=20&=20improv?= =?UTF-8?q?e=20code=20to=20handle=20page=20handling=20in=20searx=20&=20duc?= =?UTF-8?q?kduckgo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engines/duckduckgo.rs | 2 +- src/engines/searx.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engines/duckduckgo.rs b/src/engines/duckduckgo.rs index f8ad597..102da16 100644 --- a/src/engines/duckduckgo.rs +++ b/src/engines/duckduckgo.rs @@ -45,7 +45,7 @@ impl SearchEngine for DuckDuckGo { // Page number can be missing or empty string and so appropriate handling is required // so that upstream server recieves valid page number. let url: String = match page { - 1 => { + 1 | 0 => { format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js") } _ => { diff --git a/src/engines/searx.rs b/src/engines/searx.rs index 145abf1..0452a57 100644 --- a/src/engines/searx.rs +++ b/src/engines/searx.rs @@ -43,7 +43,10 @@ impl SearchEngine for Searx { ) -> Result, EngineError> { // Page number can be missing or empty string and so appropriate handling is required // so that upstream server recieves valid page number. - let url: String = format!("https://searx.work/search?q={query}&pageno={page}"); + let url: String = match page { + 0 | 1 => format!("https://searx.work/search?q={query}&pageno=1"), + _ => format!("https://searx.work/search?q={query}&pageno={page}"), + }; // initializing headers and adding appropriate headers. let mut header_map = HeaderMap::new();