Support URLs with FQDNs (trailing period on the tld)
This commit is contained in:
parent
815343e824
commit
b87be206a7
2 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue