neon_arch commited on
Commit
6fa45ec
1 Parent(s): 37e650e

✨ feat: pass the config option into the results function (#201)

Browse files
Files changed (2) hide show
  1. src/engines/duckduckgo.rs +1 -0
  2. src/engines/searx.rs +11 -2
src/engines/duckduckgo.rs CHANGED
@@ -43,6 +43,7 @@ impl SearchEngine for DuckDuckGo {
43
  page: u32,
44
  user_agent: String,
45
  request_timeout: u8,
 
46
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
47
  // Page number can be missing or empty string and so appropriate handling is required
48
  // so that upstream server recieves valid page number.
 
43
  page: u32,
44
  user_agent: String,
45
  request_timeout: u8,
46
+ _safe_search: u8,
47
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
48
  // Page number can be missing or empty string and so appropriate handling is required
49
  // so that upstream server recieves valid page number.
src/engines/searx.rs CHANGED
@@ -42,12 +42,21 @@ impl SearchEngine for Searx {
42
  page: u32,
43
  user_agent: String,
44
  request_timeout: u8,
 
45
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
46
  // Page number can be missing or empty string and so appropriate handling is required
47
  // so that upstream server recieves valid page number.
 
 
 
 
48
  let url: String = match page {
49
- 0 | 1 => format!("https://searx.work/search?q={query}&pageno=1"),
50
- _ => format!("https://searx.work/search?q={query}&pageno={page}"),
 
 
 
 
51
  };
52
 
53
  // initializing headers and adding appropriate headers.
 
42
  page: u32,
43
  user_agent: String,
44
  request_timeout: u8,
45
+ mut safe_search: u8,
46
  ) -> Result<HashMap<String, SearchResult>, EngineError> {
47
  // Page number can be missing or empty string and so appropriate handling is required
48
  // so that upstream server recieves valid page number.
49
+ if safe_search == 3 {
50
+ safe_search = 2;
51
+ };
52
+
53
  let url: String = match page {
54
+ 0 | 1 => {
55
+ format!("https://searx.work/search?q={query}&pageno=1&safesearch={safe_search}")
56
+ }
57
+ _ => format!(
58
+ "https://searx.work/search?q={query}&pageno={page}&safesearch={safe_search}"
59
+ ),
60
  };
61
 
62
  // initializing headers and adding appropriate headers.