From c9331f61b43207133bea15a4f2660ed24571203a Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 7 Sep 2020 23:19:32 -0400 Subject: [PATCH] require page number to be positive --- lib/philomena_web/plugs/pagination_plug.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/plugs/pagination_plug.ex b/lib/philomena_web/plugs/pagination_plug.ex index f1706952..0dc8da91 100644 --- a/lib/philomena_web/plugs/pagination_plug.ex +++ b/lib/philomena_web/plugs/pagination_plug.ex @@ -23,7 +23,10 @@ defmodule PhilomenaWeb.PaginationPlug do end defp get_page_number(%{"page" => page}) do - to_integer(page) || 1 + page + |> to_integer() + |> Kernel.||(1) + |> max(1) end defp get_page_number(_params), do: 1