diff --git a/lib/linkify/parser.ex b/lib/linkify/parser.ex index cba70f6..d6f1597 100644 --- a/lib/linkify/parser.ex +++ b/lib/linkify/parser.ex @@ -45,7 +45,7 @@ defmodule Linkify.Parser do @tlds "./priv/tlds.txt" |> File.read!() |> String.split("\n", trim: true) - |> Enum.concat(["onion"]) + |> Enum.concat(["onion", "i2p", "loki", "ygg"]) |> MapSet.new() @default_opts %{ @@ -205,7 +205,7 @@ defmodule Linkify.Parser do def check_and_link(:mention, buffer, opts, user_acc) do buffer - |> match_mention + |> match_mention(opts) |> link_mention(buffer, opts, user_acc) end @@ -362,7 +362,7 @@ defmodule Linkify.Parser do |> Kernel.!() end - def match_mention(buffer) do + def match_mention(buffer, opts) do case Regex.run(~r/^@(?[a-zA-Z\d_-]+)(@(?[^@]+))?$/, buffer, capture: [:user, :host] ) do @@ -370,7 +370,7 @@ defmodule Linkify.Parser do "@" <> user [user, hostname] -> - if valid_hostname?(hostname) && valid_tld?(hostname, []), + if valid_hostname?(hostname) && (valid_tld?(hostname, opts) || ip?(hostname)), do: "@" <> user <> "@" <> hostname, else: nil