Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage example #20

Closed
szepeviktor opened this issue Aug 1, 2015 · 1 comment
Closed

Usage example #20

szepeviktor opened this issue Aug 1, 2015 · 1 comment
Assignees
Labels
❌wontfix Will not be merged. Reason typically included in PR/Issue as to why

Comments

@szepeviktor
Copy link

May I put this into the Wiki?
This script outputs only the SLD part from a list of domain names.
So if you have subdomain.example.co.uk on your list, the output will be example.co.uk.

# Prepare the list for finding second-level domains
Publicsuffix_regexp() {
    local LIST_URL="https://publicsuffix.org/list/public_suffix_list.dat"

    # Download list,
    #   remove empty lines and comments,
    #   escape dots, asterisks and add SLD regexp
    wget -qO- "$LIST_URL" \
        | grep -v "^\s*$\|^\s*//" \
        | sed -e 's/\./\\./g' -e 's/\*/.*/' -e 's/^\(.*\)$/[^.]\\+\\.\1$/'
}

Publicsuffix_regexp | grep -o -f - "$YOUR_DOMAINS"

I use it for registration expiry purposes.

@weppos
Copy link
Member

weppos commented Feb 27, 2016

@szepeviktor thanks for your contributions. I'm closing this, as we don't currently add usage examples or libraries to the wiki.

Also double check your code properly reflects the formal algorithm, including the exceptions. Or you may get inaccurate results.

@weppos weppos closed this as completed Feb 27, 2016
@weppos weppos self-assigned this Feb 27, 2016
@weppos weppos added the ❌wontfix Will not be merged. Reason typically included in PR/Issue as to why label Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌wontfix Will not be merged. Reason typically included in PR/Issue as to why
Projects
None yet
Development

No branches or pull requests

2 participants