public_suffix alternatives and similar shards
Based on the "Tools" category.
Alternatively, view public_suffix alternatives based on common mentions on social networks and blogs.
Do you think we are missing an alternative of public_suffix or a related project?
The Public Suffix List is "a cross-vendor initiative to provide an accurate list of domain name suffixes". Such a list is necessary because "there was and remains no algorithmic method of finding the highest level at which a domain may be registered for a particular top-level domain...".
public_suffix is a small Crystal library designed to make the Public
Suffix List easier to use. The library will transparently download the
latest list of rules, parse the rules, and optionally cache
them. Source URL, cache directory, and cache expiry are all
The public API is as simple as I could make it. Instantiating the
PublicSuffix class creates a new instance with reasonable defaults
(downloads and caches the official list of rules for 30 days).
There are three instance methods:
PublicSuffix#tldreturns the top-level domain name
PublicSuffix#cdnreturns the canonical domain name
PublicSuffix#splitsplits the domain name into parts
- Transparent download of the official domain rules file
- Optional caching of domain rules data, with refetch upon expiry
- Tiny API
Add the dependency to your
dependencies: public_suffix: github: toddsundsted/public_suffix
require "public_suffix" # Downloads and parses the latest data file and returns # the top-level domain name PublicSuffix.new.tld("foobar.com") # => "com" # Downloads and parses the latest data file and returns # the canonical domain name PublicSuffix.new.cdn("foobar.com") # => "foobar.com" # Downloads and parses the latest data file, caches it in /tmp, # and splits the domain name into parts PublicSuffix.new(cache_dir: "/tmp").split("abc.xyz.co.uk") # => ["abc", "xyz", "co.uk"]. # Downloads and caches data in /tmp if it is less than # 100 seconds old, parses it, and splits the domain name # into parts PublicSuffix.new(cache_dir: "/tmp", cache_expiry_period: 100).split("test.parliament.uk") # => ["test", "parliament", "uk"] # You don't have to instantiate PublicSuffix every time you use it p = PublicSuffix.new p.split("fee.fi.fo.com") # => ["fee.fi", "fo", "com"] p.cdn("fee.fi.fo.com") # => "fo.com", "cdn" means "canonical domain name" p.tld("fee.fi.fo.com") # => "com", "tld" means "top-level domain" # You can even use other data files, both local and remote # (as long as they conform to the Public Suffix List file format) PublicSuffix.new(url: "file://./spec/test.dat")
- Fork it (https://github.com/toddsundsted/public_suffix/fork)
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request
- Todd Sundsted - creator and maintainer