mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-11-21 21:48:21 -05:00
✨ feat: pass the config option into the results function (#201)
This commit is contained in:
parent
37e650eb8a
commit
6fa45ecb12
@ -43,6 +43,7 @@ impl SearchEngine for DuckDuckGo {
|
||||
page: u32,
|
||||
user_agent: String,
|
||||
request_timeout: u8,
|
||||
_safe_search: u8,
|
||||
) -> Result<HashMap<String, SearchResult>, EngineError> {
|
||||
// Page number can be missing or empty string and so appropriate handling is required
|
||||
// so that upstream server recieves valid page number.
|
||||
|
@ -42,12 +42,21 @@ impl SearchEngine for Searx {
|
||||
page: u32,
|
||||
user_agent: String,
|
||||
request_timeout: u8,
|
||||
mut safe_search: u8,
|
||||
) -> Result<HashMap<String, SearchResult>, EngineError> {
|
||||
// Page number can be missing or empty string and so appropriate handling is required
|
||||
// so that upstream server recieves valid page number.
|
||||
if safe_search == 3 {
|
||||
safe_search = 2;
|
||||
};
|
||||
|
||||
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}"),
|
||||
0 | 1 => {
|
||||
format!("https://searx.work/search?q={query}&pageno=1&safesearch={safe_search}")
|
||||
}
|
||||
_ => format!(
|
||||
"https://searx.work/search?q={query}&pageno={page}&safesearch={safe_search}"
|
||||
),
|
||||
};
|
||||
|
||||
// initializing headers and adding appropriate headers.
|
||||
|
Loading…
Reference in New Issue
Block a user