Merge branch 'fix/hashtag-consistency' into 'develop'

Include the '#' symbol into the hashtag link itself

See merge request pleroma/pleroma!85
This commit is contained in:
lambda 2018-03-27 06:27:12 +00:00
commit 2e683b10d5
3 changed files with 3 additions and 3 deletions

View File

@ -189,7 +189,7 @@ def add_hashtag_links({subs, text}, tags) do
end) end)
subs = subs ++ Enum.map(tags, fn ({_, tag, uuid}) -> subs = subs ++ Enum.map(tags, fn ({_, tag, uuid}) ->
url = "#<a href='#{Pleroma.Web.base_url}/tag/#{tag}' rel='tag'>#{tag}</a>" url = "<a href='#{Pleroma.Web.base_url}/tag/#{tag}' rel='tag'>##{tag}</a>"
{uuid, url} {uuid, url}
end) end)

View File

@ -7,7 +7,7 @@ defmodule Pleroma.FormatterTest do
describe ".add_hashtag_links" do describe ".add_hashtag_links" do
test "turns hashtags into links" do test "turns hashtags into links" do
text = "I love #cofe and #2hu" text = "I love #cofe and #2hu"
expected_text = "I love #<a href='http://localhost:4001/tag/cofe' rel='tag'>cofe</a> and #<a href='http://localhost:4001/tag/2hu' rel='tag'>2hu</a>" expected_text = "I love <a href='http://localhost:4001/tag/cofe' rel='tag'>#cofe</a> and <a href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a>"
tags = Formatter.parse_tags(text) tags = Formatter.parse_tags(text)
assert expected_text == Formatter.add_hashtag_links({[], text}, tags) |> Formatter.finalize assert expected_text == Formatter.add_hashtag_links({[], text}, tags) |> Formatter.finalize

View File

@ -34,7 +34,7 @@ test "create a status" do
{ :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input) { :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
expected_text = "Hello again, <span><a href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. #<a href='http://localhost:4001/tag/2hu' rel='tag'>2hu</a> #<a href='http://localhost:4001/tag/epic' rel='tag'>epic</a> #<a href='http://localhost:4001/tag/phantasmagoric' rel='tag'>phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>" expected_text = "Hello again, <span><a href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. <a href='http://localhost:4001/tag/2hu' rel='tag'>#2hu</a> <a href='http://localhost:4001/tag/epic' rel='tag'>#epic</a> <a href='http://localhost:4001/tag/phantasmagoric' rel='tag'>#phantasmagoric</a><br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
assert get_in(activity.data, ["object", "content"]) == expected_text assert get_in(activity.data, ["object", "content"]) == expected_text
assert get_in(activity.data, ["object", "type"]) == "Note" assert get_in(activity.data, ["object", "type"]) == "Note"
assert get_in(activity.data, ["object", "actor"]) == user.ap_id assert get_in(activity.data, ["object", "actor"]) == user.ap_id