Change @link_regex to match any URL scheme

This commit is contained in:
dtluna 2018-04-13 18:30:00 +03:00
parent fef8daa454
commit c426a5d9e4
2 changed files with 10 additions and 1 deletions

View File

@ -144,7 +144,7 @@ defmodule Pleroma.Formatter do
@emoji
end
@link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~\(\):]+[\w\/]/u
@link_regex ~r/[a-z0-9]+:\/\/[\w\.\/?=\-#\+%&@~\(\):]+[\w\/]/u
def html_escape(text) do
Regex.split(@link_regex, text, include_captures: true)

View File

@ -71,6 +71,15 @@ defmodule Pleroma.FormatterTest do
"<a href='https://www.google.co.jp/search?q=Nasim+Aghdam'>https://www.google.co.jp/search?q=Nasim+Aghdam</a>"
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
text = "mumble://voluntaryism.club"
expected = "<a href='mumble://voluntaryism.club'>mumble://voluntaryism.club</a>"
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
text = "xmpp://voluntaryism.club"
expected = "<a href='xmpp://voluntaryism.club'>xmpp://voluntaryism.club</a>"
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
end
end