From: lain Date: Sat, 19 May 2018 09:27:14 +0000 (+0200) Subject: Fix linking problem. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=df95118c819ae15f0de43519f2f9f9753ac60ec2;p=akkoma Fix linking problem. --- 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 "https://en.wikipedia.org/wiki/Duff's_device" assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected + + text = "https://pleroma.com https://pleroma.com/sucks" + + expected = + "https://pleroma.com https://pleroma.com/sucks" + + assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected end end