diff --git a/lib/pleroma/web/twitter_api/utils.ex b/lib/pleroma/web/twitter_api/utils.ex index 65d893869..5cbe0cf9c 100644 --- a/lib/pleroma/web/twitter_api/utils.ex +++ b/lib/pleroma/web/twitter_api/utils.ex @@ -11,7 +11,7 @@ def attachments_from_ids(ids) do def add_attachments(text, attachments) do attachment_text = Enum.map(attachments, fn (%{"url" => [%{"href" => href} | _]}) -> - "#{Path.basename(href)}" + "#{Path.basename(href)}" _ -> "" end) Enum.join([text | attachment_text], "
\n") diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index da880e67c..6848413cc 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -34,7 +34,7 @@ test "create a status" do { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input) - assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp.
\nThis is on another line. #2hu #epic #phantasmagoric
\nimage.jpg" + assert get_in(activity.data, ["object", "content"]) == "Hello again, @shp.
\nThis is on another line. #2hu #epic #phantasmagoric
\nimage.jpg" assert get_in(activity.data, ["object", "type"]) == "Note" assert get_in(activity.data, ["object", "actor"]) == user.ap_id assert get_in(activity.data, ["actor"]) == user.ap_id diff --git a/test/web/twitter_api/twitter_api_utils_test.exs b/test/web/twitter_api/twitter_api_utils_test.exs new file mode 100644 index 000000000..62aa7843b --- /dev/null +++ b/test/web/twitter_api/twitter_api_utils_test.exs @@ -0,0 +1,14 @@ +defmodule Pleroma.Web.TwitterAPI.UtilsTest do + alias Pleroma.Web.TwitterAPI.Utils + use Pleroma.DataCase + + test "it adds attachment links to a given text and attachment set" do + attachment = %{ + "url" => [%{"href" => "http://heise.de/i\"m a boy.png"}] + } + + res = Utils.add_attachments("", [attachment]) + + assert res == "
\ni\"m a boy.png" + end +end