From d201733756bc0eb1c04cf87e5fbd5b5f7d68e129 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 29 Jul 2018 21:09:57 -0500 Subject: [PATCH] Add fix for empty 'page' param --- src/invidious.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 16a2d458..1a739ae4 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1139,7 +1139,7 @@ end get "/api/v1/channels/:ucid/videos" do |env| ucid = env.params.url["ucid"] - page = env.params.query["page"]? + page = env.params.query["page"]?.try &.to_i? page ||= 1 url = produce_videos_url(ucid, page) @@ -1346,7 +1346,7 @@ get "/search" do |env| next env.redirect "/" end - page = env.params.query["page"]?.try &.to_i + page = env.params.query["page"]?.try &.to_i? page ||= 1 client = make_client(YT_URL) @@ -1794,7 +1794,7 @@ get "/feed/subscriptions" do |env| max_results ||= env.params.query["max_results"]?.try &.to_i max_results ||= 40 - page = env.params.query["page"]?.try &.to_i + page = env.params.query["page"]?.try &.to_i? page ||= 1 if max_results < 0 @@ -1966,7 +1966,7 @@ get "/feed/private" do |env| max_results = env.params.query["max_results"]?.try &.to_i max_results ||= 40 - page = env.params.query["page"]?.try &.to_i + page = env.params.query["page"]?.try &.to_i? page ||= 1 if max_results < 0 @@ -2226,7 +2226,7 @@ get "/channel/:ucid" do |env| ucid = env.params.url["ucid"] - page = env.params.query["page"]?.try &.to_i + page = env.params.query["page"]?.try &.to_i? page ||= 1 client = make_client(YT_URL)