logo

auto_linker

AutoLinker-shim, based on https://git.pleroma.social/pleroma/auto_linker git clone https://hacktivis.me/git/auto_linker.git
commit: b87be206a72dc77787037b18b11c86200c6f2cc1
parent 815343e824f0853ec0bb8d91419e7d8f175fa820
Author: Mark Felder <feld@FreeBSD.org>
Date:   Wed, 18 Nov 2020 17:24:44 +0000

Support URLs with FQDNs (trailing period on the tld)

Diffstat:

Mlib/linkify/parser.ex2+-
Mtest/linkify_test.exs10++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git 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 @@ -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