Adjustment for parsing non-ICANN domain mentions
This commit is contained in:
parent
1e612ac3a3
commit
c77d40de20
1 changed files with 4 additions and 4 deletions
|
@ -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/^@(?<user>[a-zA-Z\d_-]+)(@(?<host>[^@]+))?$/, 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
|
||||
|
||||
|
|
Loading…
Reference in a new issue