logo

auto_linker

AutoLinker-shim, based on https://git.pleroma.social/pleroma/auto_linker git clone https://hacktivis.me/git/auto_linker.git
commit: b044a63910acba524f5e3df24ad1ed1b99088cce
parent 150d9f222f344117a41864eac3042808a7c82f8b
Author: Egor Kislitsyn <egor@kislitsyn.com>
Date:   Fri, 21 Jun 2019 18:27:01 +0700

Add doc to `valid_tld?/2`

Diffstat:

Mlib/auto_linker/parser.ex11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/auto_linker/parser.ex b/lib/auto_linker/parser.ex @@ -311,8 +311,15 @@ defmodule AutoLinker.Parser do defp valid_url?(url), do: !Regex.match?(@invalid_url, url) - def valid_tld?(buffer, opts) do - [scheme, host] = Regex.run(@match_hostname, buffer, capture: [:scheme, :host]) + @doc """ + Validates a URL's TLD. Returns a boolean. + + Will return `true` if `:validate_tld` option set to `false`. + + Will skip validation and return `true` if `:validate_tld` set to `:no_scheme` and the url has a scheme. + """ + def valid_tld?(url, opts) do + [scheme, host] = Regex.run(@match_hostname, url, capture: [:scheme, :host]) cond do opts[:validate_tld] == false ->