Skip to content

Commit

Permalink
Release 0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
weppos committed Jun 15, 2024
1 parent e034e9c commit bc7e9eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# CHANGELOG

## main
## 0.40.0

- CHANGED: Dropped Go < 1.21 from the list of supported versions.
- CHANGED: Definition updates.

## 0.30.2

Expand Down
45 changes: 20 additions & 25 deletions publicsuffix/publicsuffix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
// Version identifies the current library version.
// This is a pro forma convention given that Go dependencies
// tends to be fetched directly from the repo.
Version = "0.30.2"
Version = "0.40.1"

// NormalType represents a normal rule such as "com"
NormalType = 1
Expand Down Expand Up @@ -270,11 +270,11 @@ func MustNewRule(content string) *Rule {
// Match checks if the rule matches the name.
//
// A domain name is said to match a rule if and only if all of the following conditions are met:
// - When the domain and rule are split into corresponding labels,
// that the domain contains as many or more labels than the rule.
// - Beginning with the right-most labels of both the domain and the rule,
// and continuing for all labels in the rule, one finds that for every pair,
// either they are identical, or that the label from the rule is "*".
// - When the domain and rule are split into corresponding labels,
// that the domain contains as many or more labels than the rule.
// - Beginning with the right-most labels of both the domain and the rule,
// and continuing for all labels in the rule, one finds that for every pair,
// either they are identical, or that the label from the rule is "*".
//
// See https://publicsuffix.org/list/
func (r *Rule) Match(name string) bool {
Expand Down Expand Up @@ -356,11 +356,10 @@ type DomainName struct {
//
// Examples:
//
// DomainName{"com", "example"}.String()
// DomainName{"com", "example"}.String()
// // example.com
// DomainName{"com", "example", "www"}.String()
// DomainName{"com", "example", "www"}.String()
// // www.example.com
//
func (d *DomainName) String() string {
switch {
case d.TLD == "":
Expand All @@ -379,13 +378,12 @@ func (d *DomainName) String() string {
//
// Examples:
//
// publicsuffix.Domain("example.com")
// publicsuffix.Domain("example.com")
// // example.com
// publicsuffix.Domain("www.example.com")
// publicsuffix.Domain("www.example.com")
// // example.com
// publicsuffix.Domain("www.example.co.uk")
// publicsuffix.Domain("www.example.co.uk")
// // example.co.uk
//
func Domain(name string) (string, error) {
return DomainFromListWithOptions(DefaultList, name, DefaultFindOptions)
}
Expand All @@ -398,13 +396,12 @@ func Domain(name string) (string, error) {
//
// list := NewList()
//
// publicsuffix.Parse("example.com")
// publicsuffix.Parse("example.com")
// // &DomainName{"com", "example"}
// publicsuffix.Parse("www.example.com")
// publicsuffix.Parse("www.example.com")
// // &DomainName{"com", "example", "www"}
// publicsuffix.Parse("www.example.co.uk")
// publicsuffix.Parse("www.example.co.uk")
// // &DomainName{"co.uk", "example"}
//
func Parse(name string) (*DomainName, error) {
return ParseFromListWithOptions(DefaultList, name, DefaultFindOptions)
}
Expand All @@ -416,13 +413,12 @@ func Parse(name string) (*DomainName, error) {
//
// list := NewList()
//
// publicsuffix.DomainFromListWithOptions(list, "example.com")
// publicsuffix.DomainFromListWithOptions(list, "example.com")
// // example.com
// publicsuffix.DomainFromListWithOptions(list, "www.example.com")
// publicsuffix.DomainFromListWithOptions(list, "www.example.com")
// // example.com
// publicsuffix.DomainFromListWithOptions(list, "www.example.co.uk")
// publicsuffix.DomainFromListWithOptions(list, "www.example.co.uk")
// // example.co.uk
//
func DomainFromListWithOptions(l *List, name string, options *FindOptions) (string, error) {
dn, err := ParseFromListWithOptions(l, name, options)
if err != nil {
Expand All @@ -439,13 +435,12 @@ func DomainFromListWithOptions(l *List, name string, options *FindOptions) (stri
//
// list := NewList()
//
// publicsuffix.ParseFromListWithOptions(list, "example.com")
// publicsuffix.ParseFromListWithOptions(list, "example.com")
// // &DomainName{"com", "example"}
// publicsuffix.ParseFromListWithOptions(list, "www.example.com")
// publicsuffix.ParseFromListWithOptions(list, "www.example.com")
// // &DomainName{"com", "example", "www"}
// publicsuffix.ParseFromListWithOptions(list, "www.example.co.uk")
// publicsuffix.ParseFromListWithOptions(list, "www.example.co.uk")
// // &DomainName{"co.uk", "example"}
//
func ParseFromListWithOptions(l *List, name string, options *FindOptions) (*DomainName, error) {
n, err := normalize(name)
if err != nil {
Expand Down

0 comments on commit bc7e9eb

Please sign in to comment.