{"id":15713812,"url":"https://github.com/toddsundsted/public_suffix","last_synced_at":"2025-07-15T19:05:53.244Z","repository":{"id":66705987,"uuid":"179334084","full_name":"toddsundsted/public_suffix","owner":"toddsundsted","description":"A small Crystal library designed to make the Public Suffix List (https://publicsuffix.org/) easier to use.","archived":false,"fork":false,"pushed_at":"2021-05-01T22:09:54.000Z","size":35,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T02:49:41.918Z","etag":null,"topics":["crystal","public-suffix-list"],"latest_commit_sha":null,"homepage":null,"language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toddsundsted.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-03T17:02:44.000Z","updated_at":"2021-06-28T04:30:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"f724591e-f43e-4d14-aa56-ddd1e7e1422c","html_url":"https://github.com/toddsundsted/public_suffix","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddsundsted%2Fpublic_suffix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddsundsted%2Fpublic_suffix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddsundsted%2Fpublic_suffix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toddsundsted%2Fpublic_suffix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toddsundsted","download_url":"https://codeload.github.com/toddsundsted/public_suffix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246366729,"owners_count":20765748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crystal","public-suffix-list"],"created_at":"2024-10-03T21:33:36.686Z","updated_at":"2025-03-30T19:23:36.254Z","avatar_url":"https://github.com/toddsundsted.png","language":"Crystal","funding_links":[],"categories":["Official Documentation Translations"],"sub_categories":[],"readme":"# public_suffix\n\n[![GitHub Release](https://img.shields.io/github/release/toddsundsted/public_suffix.svg)](https://github.com/toddsundsted/public_suffix/releases)\n[![Build Status](https://travis-ci.org/toddsundsted/public_suffix.svg?branch=master)](https://travis-ci.org/toddsundsted/public_suffix)\n[![Documentation](https://img.shields.io/badge/docs-available-brightgreen.svg)](https://toddsundsted.github.io/public_suffix/)\n\nThe [Public Suffix List](https://publicsuffix.org/) is \"a cross-vendor\ninitiative to provide an accurate list of domain name suffixes\". Such\na list is necessary because \"there was and remains no algorithmic\nmethod of finding the highest level at which a domain may be\nregistered for a particular top-level domain...\".\n\n`public_suffix` is a small Crystal library designed to make the Public\nSuffix List easier to use. The library will transparently download the\nlatest list of rules, parse the rules, and optionally cache\nthem. Source URL, cache directory, and cache expiry are all\nconfigurable.\n\nThe public API is as simple as I could make it.  Instantiating the\n`PublicSuffix` class creates a new instance with reasonable defaults\n(downloads and caches the official list of rules for 30 days).\n\nThere are three instance methods:\n\n* `PublicSuffix#tld` returns the top-level domain name\n* `PublicSuffix#cdn` returns the canonical domain name\n* `PublicSuffix#split`splits the domain name into parts\n\n## Features\n\n* Transparent download of the official domain rules file\n* Optional caching of domain rules data, with refetch upon expiry\n* Tiny API\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n       dependencies:\n         public_suffix:\n           github: toddsundsted/public_suffix\n\n2. Run `shards install`\n\n## Synopsis\n\n    require \"public_suffix\"\n\n    # Downloads and parses the latest data file and returns\n    # the top-level domain name\n    PublicSuffix.new.tld(\"foobar.com\") # =\u003e \"com\"\n\n    # Downloads and parses the latest data file and returns\n    # the canonical domain name\n    PublicSuffix.new.cdn(\"foobar.com\") # =\u003e \"foobar.com\"\n\n    # Downloads and parses the latest data file, caches it in /tmp,\n    # and splits the domain name into parts\n    PublicSuffix.new(cache_dir: \"/tmp\").split(\"abc.xyz.co.uk\") # =\u003e [\"abc\", \"xyz\", \"co.uk\"].\n\n    # Downloads and caches data in /tmp if it is less than\n    # 100 seconds old, parses it, and splits the domain name\n    # into parts\n    PublicSuffix.new(cache_dir: \"/tmp\", cache_expiry_period: 100).split(\"test.parliament.uk\") # =\u003e [\"test\", \"parliament\", \"uk\"]\n\n    # You don't have to instantiate PublicSuffix every time you use it\n    p = PublicSuffix.new\n    p.split(\"fee.fi.fo.com\") # =\u003e [\"fee.fi\", \"fo\", \"com\"]\n    p.cdn(\"fee.fi.fo.com\")   # =\u003e \"fo.com\", \"cdn\" means \"canonical domain name\"\n    p.tld(\"fee.fi.fo.com\")   # =\u003e \"com\", \"tld\" means \"top-level domain\"\n\n    # You can even use other data files, both local and remote\n    # (as long as they conform to the Public Suffix List file format)\n    PublicSuffix.new(url: \"file://./spec/test.dat\")\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/toddsundsted/public_suffix/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Todd Sundsted](https://github.com/toddsundsted) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddsundsted%2Fpublic_suffix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoddsundsted%2Fpublic_suffix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoddsundsted%2Fpublic_suffix/lists"}