Skip to content

Simple CLI to extract the registrable domain (eTLD+1) from URLs or hostnames using the Public Suffix List.

License

Notifications You must be signed in to change notification settings

Firefishy/etld1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

etld1

A tiny command-line tool that extracts the registrable domain (eTLD+1) from URLs or hostnames using the Mozilla Public Suffix List.

Example:

sub.service.example.co.uk → example.co.uk
https://deep.nested.example.com/path → example.com

Install

Prebuilt binaries

Download the latest release for your platform from the Releases page.

From source

git clone https://github.com/Firefishy/etld1.git
cd etld1
go build -o etld1 .

Or with GoReleaser installed:

goreleaser build --snapshot --single-target --clean

Usage

Pipe domains or URLs into the program. Each line outputs the base registrable domain.

echo 'sub.service.example.co.uk' | ./etld1
# example.co.uk

echo 'https://deep.nested.example.com/path' | ./etld1
# example.com

cat urls.txt | ./etld1

Lines that do not parse as a URL or domain are silently skipped.


Why?

When normalising URLs, it’s often important to reduce them to the domain users actually control. For example, co.uk is controlled by the registry, but example.co.uk is registrable. This tool uses the official PSL (via Go’s x/net/publicsuffix) to get the correct base domain.


License

MIT

About

Simple CLI to extract the registrable domain (eTLD+1) from URLs or hostnames using the Public Suffix List.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages