Commit b044a639 authored by minibikini's avatar minibikini

Add doc to `valid_tld?/2`

parent 150d9f22
......@@ -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 ->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment