public_suffix 6.0.2 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CLAUDE.md ADDED
@@ -0,0 +1 @@
1
+ AGENTS.md
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,129 @@
1
+ # Contributing to PublicSuffix for Ruby
2
+
3
+ Thank you for your interest in contributing to PublicSuffix for Ruby!
4
+
5
+ ## Development Workflow
6
+
7
+ 1. Fork and clone the repository
8
+ 2. Install dependencies: `bundle install`
9
+ 3. Create a branch: `git checkout -b feature/your-feature`
10
+ 4. Make your changes
11
+ 5. Run tests: `rake test`
12
+ 6. Commit using Conventional Commits format (see below)
13
+ 7. Push and create a pull request
14
+
15
+ ## Commit Message Guidelines
16
+
17
+ We follow the [Conventional Commits](https://www.conventionalcommits.org/) specification for commit messages.
18
+
19
+ We follow the [Common Changelog](https://common-changelog.org/) format for changelog entries.
20
+
21
+ ### Format
22
+
23
+ ```
24
+ <type>(<scope>): <subject>
25
+
26
+ <body>
27
+
28
+ <footer>
29
+ ```
30
+
31
+ Use lowercase for `<type>`. Capitalize the first letter of `<subject>` (sentence-style). See examples below.
32
+
33
+ ### Type
34
+
35
+ - **feat**: A new feature
36
+ - **fix**: A bug fix
37
+ - **chore**: Other changes that don't modify src or test files
38
+ - **docs**: Documentation only changes
39
+ - **style**: Code style changes (formatting, etc.)
40
+ - **refactor**: Code change that neither fixes a bug nor adds a feature
41
+ - **perf**: Performance improvement
42
+ - **test**: Adding or updating tests
43
+ - **build**: Changes to build system or external dependencies
44
+ - **ci**: Changes to CI configuration files and scripts
45
+
46
+ ### Scope
47
+
48
+ - **parser**: List parsing and rule handling
49
+ - **domain**: Domain parsing and validation
50
+ - **list**: List management and operations
51
+ - **rule**: Rule definitions and matching
52
+
53
+ ### Examples
54
+
55
+ ```bash
56
+ feat(parser): Add support for wildcard exceptions
57
+
58
+ fix(domain): Handle FQDN trailing dots correctly
59
+
60
+ docs: Update usage examples in README
61
+
62
+ refactor(list): Simplify rule lookup logic
63
+ ```
64
+
65
+ ### Breaking Changes
66
+
67
+ Add `BREAKING CHANGE:` in the footer:
68
+
69
+ ```
70
+ feat(domain): Change parse return type
71
+
72
+ BREAKING CHANGE: Domain#parse now returns nil for invalid domains instead of raising.
73
+ Update code to check for nil returns.
74
+ ```
75
+
76
+ ## Testing
77
+
78
+ ### Running Tests
79
+
80
+ ```bash
81
+ rake test # Run all tests
82
+ rake test TEST=test/domain_test.rb # Run specific test file
83
+ ```
84
+
85
+ ### Writing Tests
86
+
87
+ - Tests use Minitest framework
88
+ - Place tests in `test/` directory
89
+ - Use descriptive test names
90
+ - Test both happy paths and error cases
91
+ - Include tests for edge cases (empty strings, unicode, etc.)
92
+
93
+ ## Pull Request Process
94
+
95
+ 1. Update documentation for API changes
96
+ 2. Add tests for new features or bug fixes
97
+ 3. Ensure all tests pass: `rake test`
98
+ 4. Use Conventional Commits format
99
+ 5. Provide clear PR description with context
100
+ 6. Reference related issues if applicable
101
+
102
+ ## Code Style
103
+
104
+ - Follow [Ruby Style Guide](https://rubystyle.guide/)
105
+ - Use RuboCop configuration if present
106
+ - Add YARD documentation for public methods
107
+ - Keep methods focused and small
108
+
109
+ ### Ruby-Specific Guidelines
110
+
111
+ - Follow idiomatic Ruby patterns
112
+ - Use meaningful variable and method names
113
+ - Prefer `raise` over `fail`
114
+ - Use blocks and iterators effectively
115
+ - Follow the principle of least surprise
116
+ - Prefer methods that return values over side effects
117
+
118
+ ### Documentation
119
+
120
+ - Add YARD comments for public methods
121
+ - Include usage examples in documentation
122
+ - Update README.md for user-facing changes
123
+ - Keep inline comments minimal - prefer self-documenting code
124
+
125
+ ## Questions?
126
+
127
+ Open an issue for questions, feature discussions, or bug reports.
128
+
129
+ Thank you for contributing!
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2025 Simone Carletti <weppos@weppos.net>
1
+ Copyright (c) 2009-2026 Simone Carletti <weppos@weppos.net>
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Public Suffix <small>for Ruby</small>
1
+ # PublicSuffix for Ruby
2
2
 
3
- <tt>PublicSuffix</tt> is a Ruby domain name parser based on the [Public Suffix List](https://publicsuffix.org/).
3
+ `PublicSuffix` is a Ruby domain name parser based on the [Public Suffix List](https://publicsuffix.org/).
4
4
 
5
5
  [![Build Status](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml/badge.svg)](https://github.com/weppos/publicsuffix-ruby/actions/workflows/tests.yml)
6
6
  [![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/public_suffix)](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix&utm_medium=referral&utm_campaign=enterprise)
@@ -16,7 +16,7 @@
16
16
 
17
17
  ## Requirements
18
18
 
19
- <tt>PublicSuffix</tt> requires **Ruby >= 3.0**. For an older versions of Ruby use a previous release.
19
+ `PublicSuffix` requires **Ruby >= 3.2**. For older versions of Ruby, use a previous release.
20
20
 
21
21
 
22
22
  ## Installation
@@ -106,9 +106,9 @@ PublicSuffix.valid?("example.tldnotlisted", default_rule: nil)
106
106
  ```
107
107
 
108
108
 
109
- ## Fully Qualified Domain Names
109
+ ## Fully qualified domain names
110
110
 
111
- This library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that end with a trailing dot.
111
+ This library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that ends with a trailing dot.
112
112
 
113
113
  ```ruby
114
114
  # Parse a standard domain name
@@ -122,7 +122,7 @@ PublicSuffix.domain("www.google.com.")
122
122
 
123
123
  ## Private domains
124
124
 
125
- This library has support for switching off support for private (non-ICANN).
125
+ This library supports toggling private (non-ICANN) domain handling.
126
126
 
127
127
  ```ruby
128
128
  # Extract a domain including private domains (by default)
@@ -148,15 +148,15 @@ PublicSuffix.domain("something.blogspot.com")
148
148
  # => "blogspot.com"
149
149
  ```
150
150
 
151
- ## Add domain to list
151
+ ## Adding custom domains
152
152
 
153
- If you want to manually add a domain to the list just run:
153
+ To manually add a domain to the list:
154
154
 
155
155
  ```ruby
156
156
  PublicSuffix::List.default << PublicSuffix::Rule.factory('onmicrosoft.com')
157
157
  ```
158
158
 
159
- ## What is the Public Suffix List?
159
+ ## What is the public suffix list?
160
160
 
161
161
  The [Public Suffix List](https://publicsuffix.org) is a cross-vendor initiative to provide an accurate list of domain name suffixes.
162
162
 
@@ -165,7 +165,7 @@ The Public Suffix List is an initiative of the Mozilla Project, but is maintaine
165
165
  A "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.
166
166
 
167
167
 
168
- ## Why the Public Suffix List is better than any available Regular Expression parser?
168
+ ## Why use the public suffix list instead of regular expressions?
169
169
 
170
170
  Previously, 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.
171
171
 
@@ -180,43 +180,52 @@ Source: https://wiki.mozilla.org/Public_Suffix_List
180
180
  Not convinced yet? Check out [this real world example](https://stackoverflow.com/q/288810/123527).
181
181
 
182
182
 
183
- ## Does <tt>PublicSuffix</tt> make requests to Public Suffix List website?
183
+ ## Does PublicSuffix make network requests?
184
184
 
185
- No. <tt>PublicSuffix</tt> comes with a bundled list. It does not make any HTTP requests to parse or validate a domain.
185
+ No. `PublicSuffix` comes with a bundled list. It does not make any HTTP requests to parse or validate a domain.
186
186
 
187
187
 
188
- ## Support
188
+ ## Terminology
189
189
 
190
- Library 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.
190
+ - **TLD** (Top-Level Domain): The last segment of a domain name. For example, in `mozilla.org`, the `.org` portion is the TLD.
191
191
 
192
- - The PublicSuffix bug tracker is here: https://github.com/weppos/publicsuffix-ruby/issues
193
- - 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.
192
+ - **SLD** (Second-Level Domain): A domain 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.
194
193
 
195
- [Consider subscribing to Tidelift which provides Enterprise support for this project](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix&utm_medium=referral&utm_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.
194
+ - **TRD** (Third-Level Domain): Also known as a subdomain, this is the part of the domain before the SLD or root domain. For example, in `https://www.mozilla.org/en-US/`, `www` is the TRD.
196
195
 
196
+ - **FQDN** (Fully Qualified Domain Name): A complete domain name that includes the hostname, domain, and top-level domain, ending with a trailing dot. The format is `[hostname].[domain].[tld].` (e.g., `www.mozilla.org.`).
197
197
 
198
- ## Security and Vulnerability Reporting
199
198
 
200
- Full information and description of our security policy please visit [`SECURITY.md`](SECURITY.md)
199
+ ## Documentation and support
201
200
 
201
+ ### Documentation
202
202
 
203
- ## Changelog
203
+ Library documentation is auto-generated from the [README](https://github.com/weppos/publicsuffix-ruby/blob/master/README.md) and source code, and is available at https://rubydoc.info/gems/public_suffix.
204
204
 
205
- See the [CHANGELOG.md](CHANGELOG.md) file for details.
205
+ ### Bug reports and contributions
206
206
 
207
+ - **Bug Tracker**: https://github.com/weppos/publicsuffix-ruby/issues
208
+ - **Code Repository**: https://github.com/weppos/publicsuffix-ruby
207
209
 
208
- ## License
210
+ Contributions are welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.
209
211
 
210
- Copyright (c) 2009-2025 Simone Carletti. This is Free Software distributed under the MIT license.
212
+ ### Enterprise support
211
213
 
212
- The [Public Suffix List source](https://publicsuffix.org/list/) is subject to the terms of the Mozilla Public License, v. 2.0.
214
+ [Consider subscribing to Tidelift](https://tidelift.com/subscription/pkg/rubygems-public-suffix?utm_source=rubygems-public-suffix&utm_medium=referral&utm_campaign=readme), which provides enterprise support for this project as part of the Tidelift Subscription. Tidelift subscriptions help fund the project, allowing us to ship releases, bugfixes, and security updates more frequently.
213
215
 
214
- ## Definitions
215
216
 
216
- tld = 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.
217
+ ## Security and vulnerability reporting
217
218
 
218
- sld = 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.
219
+ For full information and details about our security policy, please visit [`SECURITY.md`](SECURITY.md).
220
+
221
+
222
+ ## Changelog
219
223
 
220
- trd = 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.
224
+ See [CHANGELOG.md](CHANGELOG.md) for details.
221
225
 
222
- FQDN = 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]`.
226
+
227
+ ## License
228
+
229
+ Copyright (c) 2009-2026 Simone Carletti. [MIT License](LICENSE.txt).
230
+
231
+ The [Public Suffix List source](https://publicsuffix.org/list/) is subject to the terms of the Mozilla Public License, v. 2.0.
data/RELEASING.md ADDED
@@ -0,0 +1,96 @@
1
+ # Releasing
2
+
3
+ This document describes the steps to release a new version of PublicSuffix.
4
+
5
+ ## Prerequisites
6
+
7
+ - You have commit access to the repository
8
+ - You have push access to the repository
9
+ - You have a GPG key configured for signing tags
10
+ - You have permission to publish to RubyGems
11
+
12
+ ## Release process
13
+
14
+ 1. **Determine the new version** using [Semantic Versioning](https://semver.org/)
15
+
16
+ ```shell
17
+ VERSION=X.Y.Z
18
+ ```
19
+
20
+ - **MAJOR** version for incompatible API changes
21
+ - **MINOR** version for backwards-compatible functionality additions
22
+ - **PATCH** version for backwards-compatible bug fixes
23
+
24
+ 2. **Update the version file** with the new version
25
+
26
+ Edit `lib/public_suffix/version.rb` and update the `VERSION` constant:
27
+
28
+ ```ruby
29
+ VERSION = "X.Y.Z"
30
+ ```
31
+
32
+ 3. **Update the changelog** with the new version
33
+
34
+ Edit `CHANGELOG.md` and add a new section for the release following the [Common Changelog](https://common-changelog.org/) format (see [CONTRIBUTING.md](CONTRIBUTING.md) for details):
35
+
36
+ ```markdown
37
+ ## X.Y.Z - YYYY-MM-DD
38
+
39
+ ### Changed
40
+
41
+ - Description of changes
42
+ ```
43
+
44
+ 4. **Install dependencies**
45
+
46
+ ```shell
47
+ bundle install
48
+ ```
49
+
50
+ or simply:
51
+
52
+ ```shell
53
+ bundle
54
+ ```
55
+
56
+ 5. **Run tests** and confirm they pass
57
+
58
+ ```shell
59
+ bundle exec rake test
60
+ ```
61
+
62
+ 6. **Commit the new version**
63
+
64
+ ```shell
65
+ git commit -am "Release $VERSION"
66
+ ```
67
+
68
+ 7. **Create a signed tag**
69
+
70
+ ```shell
71
+ git tag -a v$VERSION -s -m "Release $VERSION"
72
+ ```
73
+
74
+ 8. **Push the changes and tag**
75
+
76
+ ```shell
77
+ git push origin main
78
+ git push origin v$VERSION
79
+ ```
80
+
81
+ 9. **Build and publish the gem**
82
+
83
+ ```shell
84
+ bundle exec rake release
85
+ ```
86
+
87
+ This will:
88
+ - Build the gem
89
+ - Push it to RubyGems
90
+ - Create a GitHub release
91
+
92
+ ## Post-release
93
+
94
+ - Verify the new version appears on [RubyGems](https://rubygems.org/gems/public_suffix)
95
+ - Verify the GitHub release was created
96
+ - Announce the release if necessary