Change @link_regex to match any URL scheme
This commit is contained in:
parent
fef8daa454
commit
c426a5d9e4
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue