parser: Add onion as an extra TLD

This commit is contained in:
Haelwenn (lanodan) Monnier 2020-11-17 16:27:47 +01:00 committed by Mark Felder
parent b50bd58d70
commit 26f5310379
2 changed files with 7 additions and 3 deletions

View file

@ -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,

View file

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