Skip to content

Commit

Permalink
Merge pull request #165 from neon-mmd/patch-searx-results-on-first-page
Browse files Browse the repository at this point in the history
🛠️ Handle page value returned from search query parameter
  • Loading branch information
neon-mmd authored Jul 31, 2023
2 parents b299766 + a8b6a9b commit 372a514
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "websurfx"
version = "0.15.1"
version = "0.15.2"
edition = "2021"
description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
repository = "https://github.com/neon-mmd/websurfx"
Expand Down
2 changes: 1 addition & 1 deletion src/engines/duckduckgo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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")
}
_ => {
Expand Down
5 changes: 4 additions & 1 deletion src/engines/searx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ impl SearchEngine for Searx {
) -> Result<HashMap<String, RawSearchResult>, 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();
Expand Down

0 comments on commit 372a514

Please sign in to comment.