neon_arch commited on
Commit
0dd25aa
β€’
1 Parent(s): d073aa2

πŸš‘οΈ fix(engine): fix the pagination code for `duckduckgo` engine (#468)

Browse files
Files changed (1) hide show
  1. src/engines/duckduckgo.rs +4 -5
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
- 1 | 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={}&s={}&dc={}&v=1&o=json&api=/d.js",
60
- query,
61
- (page / 2 + (page % 2)) * 30,
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
  };