The current url can be retrieved this way:
Phoenix.Controller.current_url(conn)
How can I get the “path” part of it?
In:
my_domain.com/path1/path2/path3?q=sfdsafdsafds
the
/path1/path2/path3
is what I want to get.
The current url can be retrieved this way:
Phoenix.Controller.current_url(conn)
How can I get the “path” part of it?
In:
my_domain.com/path1/path2/path3?q=sfdsafdsafds
the
/path1/path2/path3
is what I want to get.
You can use the URI
module:
Phoenix.Controller.current_url(conn) |> URI.parse().path
Phoenix.Controller.current_path(conn, %{})