Commit c6aa60c8 authored by lain's avatar lain
Browse files

Shorten names in links.

parent fb787731
......@@ -38,7 +38,8 @@ defmodule Pleroma.Web.TwitterAPI.Utils do
end)
Enum.reduce(mentions, step_one, fn ({match, %User{ap_id: ap_id}, uuid}, text) ->
String.replace(text, uuid, "<a href='#{ap_id}'>#{match}</a>")
short_match = String.split(match, "@") |> tl() |> hd()
String.replace(text, uuid, "<a href='#{ap_id}'>@#{short_match}</a>")
end)
end
......
......@@ -263,7 +263,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
mentions = TwitterAPI.parse_mentions(text)
expected_text = "<a href='#{gsimg.ap_id}'>@gsimg</a> According to <a href='#{archaeme.ap_id}'>@archaeme</a>, that is @daggsy. Also hello <a href='#{archaeme_remote.ap_id}'>@archaeme@archae.me</a>"
expected_text = "<a href='#{gsimg.ap_id}'>@gsimg</a> According to <a href='#{archaeme.ap_id}'>@archaeme</a>, that is @daggsy. Also hello <a href='#{archaeme_remote.ap_id}'>@archaeme</a>"
assert Utils.add_user_links(text, mentions) == expected_text
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment