PublicSuffix 2.0 contains a rewritten internal representation and comparison logic, that drastically increases the lookup performance. The new version also changes several internal and external API.
This document documents the most relevant changes to help you upgrading from PublicSuffix 1.0 to 2.0.
*
is assumed. You can override this behavior by passing a custom default rule with the default_rule
option. The old behavior can be restored by passing default_rule: nil
.PublicSuffix.domain
is a new method that parses the input and returns the domain (combination of second level domain + suffix). This is a convenient helper to parse a domain name, for example when you need to determine the cookie or SSL scope.private_domains: false
). This feature also superseded the private_domains
class-level attribute, that is no longer available.When upgrading, here's the most relevant changes to keep an eye on:
Domain#rule
, Domain#is_a_domain?
, Domain#is_a_subdomain?
, Domain#valid?
. You can easily obtain the same result by having a custom method that reconstructs the logic, and/or calling PublicSuffix.{domain|parse}(domain.to_s)
.PublicSuffix::List.private_domains
is no longer available. Instead, you now have two ways to enable/disable the private domains:
ignore_private
optionruby
PublicSuffix.domain("something.blogspot.com", ignore_private: true)
```ruby
PublicSuffix::List.default = PublicSuffix::List.parse(File.read(PublicSuffix::List::DEFAULT_LIST_PATH), private_domains: false)
PublicSuffix.domain("something.blogspot.com")
``
- Now that the library is 100% compliant with the official PublicSuffix algorithm, if a domain passed as input doesn't match any rule, the wildcard rule
*` is assumed. This means that unlisted TLDs will be considered valid by default, when they would have been invalid in 1.x. However, you can override this behavior to emulate the 1.x behavior if needed:
```ruby
PublicSuffix.valid?("google.commm")
PublicSuffix.valid?("google.commm")
PublicSuffix.valid?("google.commm", default_rule: nil)
````
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.