{"id":13747448,"url":"https://github.com/weppos/publicsuffix-ruby","last_synced_at":"2025-05-13T15:11:13.422Z","repository":{"id":710300,"uuid":"357000","full_name":"weppos/publicsuffix-ruby","owner":"weppos","description":"Domain name parser for Ruby based on the Public Suffix List.","archived":false,"fork":false,"pushed_at":"2025-05-08T09:13:54.000Z","size":1661,"stargazers_count":633,"open_issues_count":5,"forks_count":110,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-05-08T10:26:38.041Z","etag":null,"topics":["psl","publicsuffix","ruby"],"latest_commit_sha":null,"homepage":"https://simonecarletti.com/code/publicsuffix","language":"Ruby","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/weppos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["weppos"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":"rubygems/public_suffix","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2009-11-01T14:59:38.000Z","updated_at":"2025-05-08T09:13:56.000Z","dependencies_parsed_at":"2024-03-07T07:40:33.936Z","dependency_job_id":"acbade1d-d02f-4e47-96c7-8d8352031e6f","html_url":"https://github.com/weppos/publicsuffix-ruby","commit_stats":{"total_commits":823,"total_committers":42,"mean_commits":"19.595238095238095","dds":0.2940461725394897,"last_synced_commit":"1a446fec858bee685b15dce9712fdc53bda4e80a"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fpublicsuffix-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fpublicsuffix-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fpublicsuffix-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weppos%2Fpublicsuffix-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weppos","download_url":"https://codeload.github.com/weppos/publicsuffix-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253056116,"owners_count":21846695,"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":["psl","publicsuffix","ruby"],"created_at":"2024-08-03T06:01:29.329Z","updated_at":"2025-05-13T15:11:13.406Z","avatar_url":"https://github.com/weppos.png","language":"Ruby","readme":"# Public Suffix \u003csmall\u003efor Ruby\u003c/small\u003e\n\n\u003ctt\u003ePublicSuffix\u003c/tt\u003e is a Ruby domain name parser based on the [Public Suffix List](https://publicsuffix.org/).\n\n[![Build Status](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml)\n[![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/public_suffix)](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix\u0026utm_medium=referral\u0026utm_campaign=enterprise)\n\n\n## Links\n\n- [Homepage](https://simonecarletti.com/code/publicsuffix-ruby)\n- [Repository](https://github.com/weppos/publicsuffix-ruby)\n- [API Documentation](https://rubydoc.info/gems/public_suffix)\n- [Introducing the Public Suffix List library for Ruby](https://simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/)\n\n\n## Requirements\n\n\u003ctt\u003ePublicSuffix\u003c/tt\u003e requires **Ruby \u003e= 3.0**. For an older versions of Ruby use a previous release.\n\n\n## Installation\n\nYou can install the gem manually:\n\n```shell\ngem install public_suffix\n```\n\nOr use Bundler and define it as a dependency in your `Gemfile`:\n\n```ruby\ngem 'public_suffix'\n```\n\n## Usage\n\nExtract the domain out from a name:\n\n```ruby\nPublicSuffix.domain(\"google.com\")\n# =\u003e \"google.com\"\nPublicSuffix.domain(\"www.google.com\")\n# =\u003e \"google.com\"\nPublicSuffix.domain(\"www.google.co.uk\")\n# =\u003e \"google.co.uk\"\n```\n\nParse a domain without subdomains:\n\n```ruby\ndomain = PublicSuffix.parse(\"google.com\")\n# =\u003e #\u003cPublicSuffix::Domain\u003e\ndomain.tld\n# =\u003e \"com\"\ndomain.sld\n# =\u003e \"google\"\ndomain.trd\n# =\u003e nil\ndomain.domain\n# =\u003e \"google.com\"\ndomain.subdomain\n# =\u003e nil\n```\n\nParse a domain with subdomains:\n\n```ruby\ndomain = PublicSuffix.parse(\"www.google.com\")\n# =\u003e #\u003cPublicSuffix::Domain\u003e\ndomain.tld\n# =\u003e \"com\"\ndomain.sld\n# =\u003e \"google\"\ndomain.trd\n# =\u003e \"www\"\ndomain.domain\n# =\u003e \"google.com\"\ndomain.subdomain\n# =\u003e \"www.google.com\"\n```\n\nSimple validation example:\n\n```ruby\nPublicSuffix.valid?(\"google.com\")\n# =\u003e true\n\nPublicSuffix.valid?(\"www.google.com\")\n# =\u003e true\n\n# Explicitly forbidden, it is listed as a private domain\nPublicSuffix.valid?(\"blogspot.com\")\n# =\u003e false\n\n# Unknown/not-listed TLD domains are valid by default\nPublicSuffix.valid?(\"example.tldnotlisted\")\n# =\u003e true\n```\n\nStrict validation (without applying the default * rule):\n\n```ruby\nPublicSuffix.valid?(\"example.tldnotlisted\", default_rule: nil)\n# =\u003e false\n```\n\n\n## Fully Qualified Domain Names\n\nThis library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that end with a trailing dot.\n\n```ruby\n# Parse a standard domain name\nPublicSuffix.domain(\"www.google.com\")\n# =\u003e \"google.com\"\n\n# Parse a fully qualified domain name\nPublicSuffix.domain(\"www.google.com.\")\n# =\u003e \"google.com\"\n```\n\n## Private domains\n\nThis library has support for switching off support for private (non-ICANN).\n\n```ruby\n# Extract a domain including private domains (by default)\nPublicSuffix.domain(\"something.blogspot.com\")\n# =\u003e \"something.blogspot.com\"\n\n# Extract a domain excluding private domains\nPublicSuffix.domain(\"something.blogspot.com\", ignore_private: true)\n# =\u003e \"blogspot.com\"\n\n# It also works for #parse and #valid?\nPublicSuffix.parse(\"something.blogspot.com\", ignore_private: true)\nPublicSuffix.valid?(\"something.blogspot.com\", ignore_private: true)\n```\n\nIf you don't care about private domains at all, it's more efficient to exclude them when the list is parsed:\n\n```ruby\n# Disable support for private TLDs\nPublicSuffix::List.default = PublicSuffix::List.parse(File.read(PublicSuffix::List::DEFAULT_LIST_PATH), private_domains: false)\n# =\u003e \"blogspot.com\"\nPublicSuffix.domain(\"something.blogspot.com\")\n# =\u003e \"blogspot.com\"\n```\n\n## Add domain to list\n\nIf you want to manually add a domain to the list just run:\n\n```ruby\nPublicSuffix::List.default \u003c\u003c PublicSuffix::Rule.factory('onmicrosoft.com')\n```\n\n## What is the Public Suffix List?\n\nThe [Public Suffix List](https://publicsuffix.org) is a cross-vendor initiative to provide an accurate list of domain name suffixes.\n\nThe Public Suffix List is an initiative of the Mozilla Project, but is maintained as a community resource. It is available for use in any software, but was originally created to meet the needs of browser manufacturers.\n\nA \"public suffix\" is one under which Internet users can directly register names. Some examples of public suffixes are \".com\", \".co.uk\" and \"pvt.k12.wy.us\". The Public Suffix List is a list of all known public suffixes.\n\n\n## Why the Public Suffix List is better than any available Regular Expression parser?\n\nPreviously, browsers used an algorithm which basically only denied setting wide-ranging cookies for top-level domains with no dots (e.g. com or org). However, this did not work for top-level domains where only third-level registrations are allowed (e.g. co.uk). In these cases, websites could set a cookie for co.uk which will be passed onto every website registered under co.uk.\n\nClearly, this was a security risk as it allowed websites other than the one setting the cookie to read it, and therefore potentially extract sensitive information.\n\nSince there is no algorithmic method of finding the highest level at which a domain may be registered for a particular top-level domain (the policies differ with each registry), the only method is to create a list of all top-level domains and the level at which domains can be registered. This is the aim of the effective TLD list.\n\nAs well as being used to prevent cookies from being set where they shouldn't be, the list can also potentially be used for other applications where the registry controlled and privately controlled parts of a domain name need to be known, for example when grouping by top-level domains.\n\nSource: https://wiki.mozilla.org/Public_Suffix_List\n\nNot convinced yet? Check out [this real world example](https://stackoverflow.com/q/288810/123527).\n\n\n## Does \u003ctt\u003ePublicSuffix\u003c/tt\u003e make requests to Public Suffix List website?\n\nNo. \u003ctt\u003ePublicSuffix\u003c/tt\u003e comes with a bundled list. It does not make any HTTP requests to parse or validate a domain.\n\n\n## Support\n\nLibrary documentation is auto-generated from the [README](https://github.com/weppos/publicsuffix-ruby/blob/master/README.md) and the source code, and it's available at https://rubydoc.info/gems/public_suffix.\n\n- The PublicSuffix bug tracker is here: https://github.com/weppos/publicsuffix-ruby/issues\n- The PublicSuffix code repository is here: https://github.com/weppos/publicsuffix-ruby. Contributions are welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.\n\n[Consider subscribing to Tidelift which provides Enterprise support for this project](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix\u0026utm_medium=referral\u0026utm_campaign=readme) as part of the Tidelift Subscription. Tidelift subscriptions also help the maintainers by funding the project, which in turn allows us to ship releases, bugfixes, and security updates more often.\n\n\n## Security and Vulnerability Reporting\n\nFull information and description of our security policy please visit [`SECURITY.md`](SECURITY.md)\n\n\n## Changelog\n\nSee the [CHANGELOG.md](CHANGELOG.md) file for details.\n\n\n## License\n\nCopyright (c) 2009-2025 Simone Carletti. This is Free Software distributed under the MIT license.\n\nThe [Public Suffix List source](https://publicsuffix.org/list/) is subject to the terms of the Mozilla Public License, v. 2.0.\n\n## Definitions\n\ntld = Top level domain, this is in reference to the last segment of a domain, sometimes the part that is directly after the \"dot\" symbol. For example, `mozilla.org`, the `.org` portion is the tld.\n\nsld = Second level domain, a domain that is directly below a top-level domain. For example, in `https://www.mozilla.org/en-US/`, `mozilla` is the second-level domain of the .org tld.\n\ntrd = Transit routing domain, or known as a subdomain. This is the part of the domain that is before the sld or root domain. For example, in `https://www.mozilla.org/en-US/`, `www` is the trd.\n\nFQDN = Fully Qualified Domain Names, are domain names that are written with the hostname and the domain name, and include the top-level domain, the format looks like `[hostname].[domain].[tld].` for ex. `[www].[mozilla].[org]`.\n","funding_links":["https://github.com/sponsors/weppos","https://tidelift.com/funding/github/rubygems/public_suffix","https://tidelift.com/badges/package/rubygems/public_suffix","https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix\u0026utm_medium=referral\u0026utm_campaign=enterprise","https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix\u0026utm_medium=referral\u0026utm_campaign=readme"],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweppos%2Fpublicsuffix-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweppos%2Fpublicsuffix-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweppos%2Fpublicsuffix-ruby/lists"}