From 26f5310379effc184e8e93c13b4f26c3d6528e62 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Tue, 17 Nov 2020 16:27:47 +0100 Subject: [PATCH] parser: Add onion as an extra TLD --- lib/linkify/parser.ex | 6 +++++- test/parser_test.exs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index d329e37..1b82f8e 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -41,7 +41,11 @@ defmodule Linkify.Parser do "ssb://" ] - @tlds "./priv/tlds.txt" |> File.read!() |> String.split("\n", trim: true) |> MapSet.new() + @tlds "./priv/tlds.txt" + |> File.read!() + |> String.split("\n", trim: true) + |> Enum.concat(["onion"]) + |> MapSet.new() @default_opts %{ url: true, diff --git a/test/parser_test.exs b/test/parser_test.exs index 8692f46..5d83a6a 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -304,7 +304,7 @@ defmodule Linkify.ParserTest do "misskey.loki" ] - def valid_emails, do: ["rms@ai.mit.edu", "vc@cock.li"] + def valid_emails, do: ["rms@ai.mit.edu", "vc@cock.li", "guardian@33y6fjyhs3phzfjj.onion"] def invalid_emails, do: ["rms[at]ai.mit.edu", "vc@cock", "xmpp:lain@trashserver.net"] - def valid_custom_tld_emails, do: ["guardian@33y6fjyhs3phzfjj.onion", "hi@company.null"] + def valid_custom_tld_emails, do: ["hi@company.null"] end