forked from AkkomaGang/akkoma
Fix linking problem.
This commit is contained in:
parent
125d934bc6
commit
df95118c81
2 changed files with 8 additions and 0 deletions
|
@ -160,6 +160,7 @@ def add_links({subs, text}) do
|
||||||
links =
|
links =
|
||||||
Regex.scan(@link_regex, text)
|
Regex.scan(@link_regex, text)
|
||||||
|> Enum.map(fn [url] -> {Ecto.UUID.generate(), url} end)
|
|> Enum.map(fn [url] -> {Ecto.UUID.generate(), url} end)
|
||||||
|
|> Enum.sort_by(fn ({_, url}) -> -String.length(url) end)
|
||||||
|
|
||||||
uuid_text =
|
uuid_text =
|
||||||
links
|
links
|
||||||
|
|
|
@ -78,6 +78,13 @@ test "turning urls into links" do
|
||||||
"<a href=\"https://en.wikipedia.org/wiki/Duff's_device\">https://en.wikipedia.org/wiki/Duff's_device</a>"
|
"<a href=\"https://en.wikipedia.org/wiki/Duff's_device\">https://en.wikipedia.org/wiki/Duff's_device</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
|
text = "https://pleroma.com https://pleroma.com/sucks"
|
||||||
|
|
||||||
|
expected =
|
||||||
|
"<a href=\"https://pleroma.com\">https://pleroma.com</a> <a href=\"https://pleroma.com/sucks\">https://pleroma.com/sucks</a>"
|
||||||
|
|
||||||
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue