-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
I have the given requirement, given an arbitrary string, check if any valid domains are listed in the string and highlight/linkify them. I already have a basic regex to split the string into potential domains.
I would like there to be a function in PublicSuffix that could more readily answer this. Right now I am using:
@doc """
Check if the given host contains a valid TLD that does not comprise the entire
host (since we don't want to create a link to a TLD)
"""
def valid_tld?(%URI{host: nil}), do: false
def valid_tld?(%URI{host: host}) do
rule = PublicSuffix.prevailing_rule(host)
rule != "*" && rule != host
end
Which I guess seems simple enough but it might be nice to have some sort of helper.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels