diff --git a/lib/philomena_web/plugs/user_attribution_plug.ex b/lib/philomena_web/plugs/user_attribution_plug.ex index f2fb2ed6..bfbd5da8 100644 --- a/lib/philomena_web/plugs/user_attribution_plug.ex +++ b/lib/philomena_web/plugs/user_attribution_plug.ex @@ -24,7 +24,7 @@ defmodule PhilomenaWeb.UserAttributionPlug do attributes = [ ip: remote_ip, fingerprint: fingerprint(conn, conn.path_info), - referrer: conn.assigns.referrer, + referrer: referrer(conn.assigns.referrer), user: user, user_agent: user_agent(conn) ] @@ -47,4 +47,7 @@ defmodule PhilomenaWeb.UserAttributionPlug do defp fingerprint(conn, _) do conn.cookies["_ses"] end + + defp referrer(nil), do: nil + defp referrer(r), do: String.slice(r, 0, 255) end