neon_arch commited on
Commit
a8791de
โ€ข
1 Parent(s): 71c890b

๐Ÿ› ๏ธ fix: add & improve code to handle page handling in searx & duckduckgo

Browse files
src/engines/duckduckgo.rs CHANGED
@@ -45,7 +45,7 @@ impl SearchEngine for DuckDuckGo {
45
  // Page number can be missing or empty string and so appropriate handling is required
46
  // so that upstream server recieves valid page number.
47
  let url: String = match page {
48
- 1 => {
49
  format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
50
  }
51
  _ => {
 
45
  // Page number can be missing or empty string and so appropriate handling is required
46
  // so that upstream server recieves valid page number.
47
  let url: String = match page {
48
+ 1 | 0 => {
49
  format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
50
  }
51
  _ => {
src/engines/searx.rs CHANGED
@@ -43,7 +43,10 @@ impl SearchEngine for Searx {
43
  ) -> Result<HashMap<String, RawSearchResult>, EngineError> {
44
  // Page number can be missing or empty string and so appropriate handling is required
45
  // so that upstream server recieves valid page number.
46
- let url: String = format!("https://searx.work/search?q={query}&pageno={page}");
 
 
 
47
 
48
  // initializing headers and adding appropriate headers.
49
  let mut header_map = HeaderMap::new();
 
43
  ) -> Result<HashMap<String, RawSearchResult>, EngineError> {
44
  // Page number can be missing or empty string and so appropriate handling is required
45
  // so that upstream server recieves valid page number.
46
+ let url: String = match page {
47
+ 0 | 1 => format!("https://searx.work/search?q={query}&pageno=1"),
48
+ _ => format!("https://searx.work/search?q={query}&pageno={page}"),
49
+ };
50
 
51
  // initializing headers and adding appropriate headers.
52
  let mut header_map = HeaderMap::new();