diff --git a/lib/chiya/notes/note.ex b/lib/chiya/notes/note.ex index fa1e65b..c906081 100644 --- a/lib/chiya/notes/note.ex +++ b/lib/chiya/notes/note.ex @@ -3,6 +3,11 @@ defmodule Chiya.Notes.Note do import Ecto.Changeset alias Chiya.Notes.{Note, NoteSlug, NoteNote, NoteTag} + use Phoenix.VerifiedRoutes, + endpoint: ChiyaWeb.Endpoint, + router: ChiyaWeb.Router, + statics: ChiyaWeb.static_paths() + @reserved_slugs ~w(user admin dev api) @derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels]} @@ -46,7 +51,8 @@ defmodule Chiya.Notes.Note do end def note_url(note) do - URI.merge(ChiyaWeb.Endpoint.url(), note.slug) |> to_string() + URI.merge(ChiyaWeb.Endpoint.url(), ~p"/note/#{note.slug}") + |> to_string() end @doc false diff --git a/lib/chiya_web/controllers/comment_controller.ex b/lib/chiya_web/controllers/comment_controller.ex index 0e2a162..585a47c 100644 --- a/lib/chiya_web/controllers/comment_controller.ex +++ b/lib/chiya_web/controllers/comment_controller.ex @@ -18,7 +18,7 @@ defmodule ChiyaWeb.CommentController do {:ok, _comment} -> redirect(conn, to: ~p"/note/#{note_slug}?error=0") - {:error, changeset} -> + {:error, _changeset} -> redirect(conn, to: ~p"/note/#{note_slug}?error=1") end end