Handle + in links.
authorlain <lain@soykaf.club>
Wed, 4 Apr 2018 09:29:03 +0000 (11:29 +0200)
committerlain <lain@soykaf.club>
Wed, 4 Apr 2018 09:29:03 +0000 (11:29 +0200)
lib/pleroma/formatter.ex
test/formatter_test.exs

index 3634a8f5bd5292520559dfa01be2528b7ff878f5..b30e04e3d907b0f9404df1f43d2be33ae445556b 100644 (file)
@@ -144,7 +144,7 @@ defmodule Pleroma.Formatter do
     @emoji
   end
 
-  @link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~\(\)]+[\w\/]/u
+  @link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~\(\)]+[\w\/]/u
 
   def html_escape(text) do
     Regex.split(@link_regex, text, include_captures: true)
index d9cef8abc53e77b5bc9c148aee7c7e33ce9cf05a..ff882f8f1ae1ad96823451de5ed589e3808c257c 100644 (file)
@@ -57,6 +57,13 @@ defmodule Pleroma.FormatterTest do
         "<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.add_links({[], text}) |> Formatter.finalize() == expected
+
+      text = "https://www.google.co.jp/search?q=Nasim+Aghdam"
+
+      expected =
+        "<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
     end
   end