aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-05-19 11:27:14 +0200
committerlain <lain@soykaf.club>2018-05-19 11:27:14 +0200
commitdf95118c819ae15f0de43519f2f9f9753ac60ec2 (patch)
tree7fbc5bb83b365bcfea57a9fdd258f0bf6ca82b84
parent125d934bc6d8121f600e7fde9aae0a767f6aa66e (diff)
downloadpleroma-df95118c819ae15f0de43519f2f9f9753ac60ec2.tar.gz
Fix linking problem.
-rw-r--r--lib/pleroma/formatter.ex1
-rw-r--r--test/formatter_test.exs7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex
index 456416fbd..395a0ac55 100644
--- a/lib/pleroma/formatter.ex
+++ b/lib/pleroma/formatter.ex
@@ -160,6 +160,7 @@ defmodule Pleroma.Formatter do
links =
Regex.scan(@link_regex, text)
|> Enum.map(fn [url] -> {Ecto.UUID.generate(), url} end)
+ |> Enum.sort_by(fn ({_, url}) -> -String.length(url) end)
uuid_text =
links
diff --git a/test/formatter_test.exs b/test/formatter_test.exs
index 2cf1f3f8e..e89b36663 100644
--- a/test/formatter_test.exs
+++ b/test/formatter_test.exs
@@ -78,6 +78,13 @@ defmodule Pleroma.FormatterTest do
"<a href=\"https://en.wikipedia.org/wiki/Duff&#39;s_device\">https://en.wikipedia.org/wiki/Duff&#39;s_device</a>"
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