Fix parsing links with hashtag characters

Closes #1008

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-01-18 12:46:33 +01:00
parent bda18a2150
commit c8735e5837
2 changed files with 17 additions and 40 deletions

View File

@@ -112,6 +112,20 @@ defmodule Mobilizon.Service.FormatterTest do
"<a href=\"#{text}\" target=\"_blank\" rel=\"noopener noreferrer ugc\">#{text}</a>"
assert {^expected, [], []} = Formatter.linkify(text)
text = "https://example.org/#foobar"
expected =
"<a href=\"#{text}\" target=\"_blank\" rel=\"noopener noreferrer ugc\">#{text}</a>"
assert {^expected, [], []} = Formatter.linkify(text)
text = "<p>An article tagged with a #tag.</p>"
expected =
"<p>An article tagged with a <a class=\"hashtag\" data-tag=\"tag\" href=\"http://mobilizon.test/tag/tag\" rel=\"tag ugc\">#tag</a>.</p>"
assert {^expected, [], [{"#tag", "tag"}]} = Formatter.linkify(text)
end
end