Spaces:
Runtime error
Runtime error
neon_arch
commited on
Commit
β’
0dd25aa
1
Parent(s):
d073aa2
ποΈ fix(engine): fix the pagination code for `duckduckgo` engine (#468)
Browse files
src/engines/duckduckgo.rs
CHANGED
@@ -51,15 +51,14 @@ impl SearchEngine for DuckDuckGo {
|
|
51 |
// Page number can be missing or empty string and so appropriate handling is required
|
52 |
// so that upstream server recieves valid page number.
|
53 |
let url: String = match page {
|
54 |
-
|
55 |
format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
|
56 |
}
|
57 |
_ => {
|
58 |
format!(
|
59 |
-
"https://duckduckgo.com/html/?q={}&s={}&dc={}&v=1&o=json&api=/d.js",
|
60 |
-
|
61 |
-
|
62 |
-
(page / 2 + (page % 2)) * 30 + 1
|
63 |
)
|
64 |
}
|
65 |
};
|
|
|
51 |
// Page number can be missing or empty string and so appropriate handling is required
|
52 |
// so that upstream server recieves valid page number.
|
53 |
let url: String = match page {
|
54 |
+
0 => {
|
55 |
format!("https://html.duckduckgo.com/html/?q={query}&s=&dc=&v=1&o=json&api=/d.js")
|
56 |
}
|
57 |
_ => {
|
58 |
format!(
|
59 |
+
"https://duckduckgo.com/html/?q={query}&s={}&dc={}&v=1&o=json&api=/d.js",
|
60 |
+
page * 30,
|
61 |
+
page * 30 + 1
|
|
|
62 |
)
|
63 |
}
|
64 |
};
|