Allow parentheses in links.
authoreal <eal@waifu.club>
Thu, 7 Dec 2017 19:38:31 +0000 (21:38 +0200)
committereal <eal@waifu.club>
Thu, 7 Dec 2017 19:38:31 +0000 (21:38 +0200)
lib/pleroma/formatter.ex
test/formatter_test.exs

index 275c60f32634a705ff02bc82b6cdae2377f947a3..c98db2d94302987ab864c5f2f655cacebe74520f 100644 (file)
@@ -1,7 +1,7 @@
 defmodule Pleroma.Formatter do
   alias Pleroma.User
 
-  @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~]+[\w\/]/u
+  @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~\(\)]+[\w\/]/u
   def linkify(text) do
     Regex.replace(@link_regex, text, "<a href='\\0'>\\0</a>")
   end
index f919738812c696c3b357880cd631cf1e2888364f..cb7695e8e1c2b3576d242dcc77d03e55fcb54b89 100644 (file)
@@ -25,6 +25,16 @@ defmodule Pleroma.FormatterTest do
       expected = "<a href='http://www.cs.vu.nl/~ast/intel/'>http://www.cs.vu.nl/~ast/intel/</a>"
 
       assert Formatter.linkify(text) == expected
+
+      text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087"
+      expected = "<a href='https://forum.zdoom.org/viewtopic.php?f=44&t=57087'>https://forum.zdoom.org/viewtopic.php?f=44&t=57087</a>"
+
+      assert Formatter.linkify(text) == expected
+
+      text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
+      expected = "<a href='https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul'>https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul</a>"
+
+      assert Formatter.linkify(text) == expected
     end
   end