diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index 64d08db..d329e37 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -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 diff --git a/test/linkify_test.exs b/test/linkify_test.exs index 73ff6d0..f7bfc68 100644 --- a/test/linkify_test.exs +++ b/test/linkify_test.exs @@ -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: https://www.wired.com./story/marissa-mayer-startup-sunshine-contacts/" + + assert Linkify.link(text) == expected + end end end