require page number to be positive

This commit is contained in:
byte[] 2020-09-07 23:19:32 -04:00
parent ea0c9a8650
commit c9331f61b4

View file

@ -23,7 +23,10 @@ defmodule PhilomenaWeb.PaginationPlug do
end end
defp get_page_number(%{"page" => page}) do defp get_page_number(%{"page" => page}) do
to_integer(page) || 1 page
|> to_integer()
|> Kernel.||(1)
|> max(1)
end end
defp get_page_number(_params), do: 1 defp get_page_number(_params), do: 1