Support URLs with FQDNs (trailing period on the tld)

This commit is contained in:
Mark Felder 2020-11-18 17:24:44 +00:00
parent 815343e824
commit b87be206a7
2 changed files with 11 additions and 1 deletions

View file

@ -247,7 +247,7 @@ defmodule Linkify.Parser do
true
true ->
tld = host |> String.split(".") |> List.last()
tld = host |> String.trim_trailing(".") |> String.split(".") |> List.last()
MapSet.member?(@tlds, tld)
end
end

View file

@ -657,5 +657,15 @@ defmodule LinkifyTest do
assert Linkify.link(text) == expected
end
test "FQDN (with trailing period)" do
text =
"Check out this article: https://www.wired.com./story/marissa-mayer-startup-sunshine-contacts/"
expected =
"Check out this article: <a href=\"https://www.wired.com./story/marissa-mayer-startup-sunshine-contacts/\">https://www.wired.com./story/marissa-mayer-startup-sunshine-contacts/</a>"
assert Linkify.link(text) == expected
end
end
end