diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2021-06-14 17:10:02 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2021-06-14 17:27:47 +0200 |
| commit | 3de92b337db9388152caf0e931cfbb07822198df (patch) | |
| tree | 9862a5e517bf59981d0ed9d04ba79073f57ffff8 | |
| parent | a2f5342a83f2b68a1a980eb5f1e92f3f74188ab9 (diff) | |
| download | invidious-3de92b337db9388152caf0e931cfbb07822198df.tar.gz invidious-3de92b337db9388152caf0e931cfbb07822198df.tar.bz2 invidious-3de92b337db9388152caf0e931cfbb07822198df.zip | |
Use if/else instead of return in search route
| -rw-r--r-- | src/invidious/routes/search.cr | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/invidious/routes/search.cr b/src/invidious/routes/search.cr index cb05435e..513904b8 100644 --- a/src/invidious/routes/search.cr +++ b/src/invidious/routes/search.cr @@ -45,27 +45,26 @@ class Invidious::Routes::Search < Invidious::Routes::BaseRoute # Display the full page search box implemented in #1977 env.set "search", "" templated "search_homepage", navbar_search: false - return - end + else + page = env.params.query["page"]?.try &.to_i? + page ||= 1 - page = env.params.query["page"]?.try &.to_i? - page ||= 1 + user = env.get? "user" - user = env.get? "user" + begin + search_query, count, videos, operators = process_search_query(query, page, user, region: region) + rescue ex + return error_template(500, ex) + end - begin - search_query, count, videos, operators = process_search_query(query, page, user, region: region) - rescue ex - return error_template(500, ex) - end + operator_hash = {} of String => String + operators.each do |operator| + key, value = operator.downcase.split(":") + operator_hash[key] = value + end - operator_hash = {} of String => String - operators.each do |operator| - key, value = operator.downcase.split(":") - operator_hash[key] = value + env.set "search", query + templated "search" end - - env.set "search", query - templated "search" end end |
