fix: Allow post ids with slashes

This commit is contained in:
Robert Prehn 2021-03-25 16:50:57 -05:00
parent def0c8b804
commit 8a0f3c30ed
2 changed files with 5 additions and 8 deletions

View file

@ -4,6 +4,7 @@ stages:
- deploy - deploy
cache: cache:
key: dependencies
paths: paths:
- _build/ - _build/
- deps/ - deps/

View file

@ -58,14 +58,7 @@ defmodule Content.PostsController do
conn |> index_posts(%{"id" => "blog", "page" => page_string}) conn |> index_posts(%{"id" => "blog", "page" => page_string})
end end
def show(conn, %{"id" => id, "page" => page_string}) when is_list(id) do def show(conn, %{"id" => id, "page" => page_string}) when is_binary(id) or is_integer(id) do
show(conn, %{
"id" => Enum.join(id, "/"),
"page" => page_string
})
end
def show(conn, %{"id" => id, "page" => page_string}) do
post = Posts.get_post(id) post = Posts.get_post(id)
if is_nil(post) do if is_nil(post) do
@ -74,6 +67,9 @@ defmodule Content.PostsController do
conn |> show_one(post, page_string) conn |> show_one(post, page_string)
end end
end end
def show(conn, %{"id" => id, "page" => page_string}) when is_list(id) do
show(conn, %{"id" => Enum.join(id, "/"), "page" => "1"})
end
def show(conn, %{"id" => id}), do: show(conn, %{"id" => id, "page" => "1"}) def show(conn, %{"id" => id}), do: show(conn, %{"id" => id, "page" => "1"})
defp try_static_post(conn, id) do defp try_static_post(conn, id) do