diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index 73e7c3d..15c341e 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -19,7 +19,7 @@ defmodule Linkify.Parser do @match_skipped_tag ~r/^(?(a|code|pre)).*>*/ - @delimiters ~r/[,.;:>]*$/ + @delimiters ~r/[,.;:>?!]*$/ @prefix_extra [ "magnet:?", @@ -249,7 +249,7 @@ defmodule Linkify.Parser do true true -> - tld = host |> String.trim_trailing(".") |> String.split(".") |> List.last() + tld = host |> strip_punctuation() |> String.split(".") |> List.last() MapSet.member?(@tlds, tld) end end diff --git a/test/linkify_test.exs b/test/linkify_test.exs index 164a34e..32df145 100644 --- a/test/linkify_test.exs +++ b/test/linkify_test.exs @@ -675,13 +675,33 @@ defmodule LinkifyTest do assert Linkify.link(text) == expected end - test "Does not link trailing punctuation" do + test "Do not link trailing punctuation" do text = "You can find more info at https://pleroma.social." expected = "You can find more info at https://pleroma.social." assert Linkify.link(text) == expected + + text = "Of course it was google.com!!" + + expected = "Of course it was google.com!!" + + assert Linkify.link(text) == expected + + text = + "First I had to login to hotmail.com, then I had to delete emails because my 15MB quota was full." + + expected = + "First I had to login to hotmail.com, then I had to delete emails because my 15MB quota was full." + + assert Linkify.link(text) == expected + + text = "I looked at theonion.com; it was no longer funny." + + expected = "I looked at theonion.com; it was no longer funny." + + assert Linkify.link(text) == expected end test "IDN and punycode domain" do @@ -693,7 +713,8 @@ defmodule LinkifyTest do text = "xn--fraubcher-u9a.com says Neiiighhh!" - expected = "xn--fraubcher-u9a.com says Neiiighhh!" + expected = + "xn--fraubcher-u9a.com says Neiiighhh!" assert Linkify.link(text) == expected end