public_suffix 4.0.7 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +17 -6
- data/.github/workflows/psl-update.yml +38 -0
- data/.github/workflows/release.yml +5 -3
- data/.github/workflows/tests.yml +8 -7
- data/.rubocop.yml +1 -0
- data/.rubocop_opinionated.yml +0 -28
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/Rakefile +3 -3
- data/data/list.txt +318 -164
- data/lib/public_suffix/list.rb +1 -1
- data/lib/public_suffix/rule.rb +5 -5
- data/lib/public_suffix/version.rb +1 -1
- data/lib/public_suffix.rb +1 -1
- data/public_suffix.gemspec +1 -1
- data/test/acceptance_test.rb +4 -4
- data/test/psl_test.rb +1 -1
- data/test/unit/domain_test.rb +3 -3
- data/test/unit/list_test.rb +1 -1
- data/test/unit/rule_test.rb +15 -15
- metadata +7 -6
data/lib/public_suffix/list.rb
CHANGED
data/lib/public_suffix/rule.rb
CHANGED
@@ -125,7 +125,7 @@ module PublicSuffix
|
|
125
125
|
# @param private [Boolean]
|
126
126
|
def initialize(value:, length: nil, private: false)
|
127
127
|
@value = value.to_s
|
128
|
-
@length = length || @value.count(DOT) + 1
|
128
|
+
@length = length || (@value.count(DOT) + 1)
|
129
129
|
@private = private
|
130
130
|
end
|
131
131
|
|
@@ -161,7 +161,7 @@ module PublicSuffix
|
|
161
161
|
# @param name [String] the domain name to check
|
162
162
|
# @return [Boolean]
|
163
163
|
def match?(name)
|
164
|
-
#
|
164
|
+
# NOTE: it works because of the assumption there are no
|
165
165
|
# rules like foo.*.com. If the assumption is incorrect,
|
166
166
|
# we need to properly walk the input and skip parts according
|
167
167
|
# to wildcard component.
|
@@ -221,7 +221,7 @@ module PublicSuffix
|
|
221
221
|
# @param content [String] the content of the rule
|
222
222
|
# @param private [Boolean]
|
223
223
|
def self.build(content, private: false)
|
224
|
-
new(value: content.to_s[2
|
224
|
+
new(value: content.to_s[2..], private: private)
|
225
225
|
end
|
226
226
|
|
227
227
|
# Initializes a new rule.
|
@@ -269,7 +269,7 @@ module PublicSuffix
|
|
269
269
|
# @param content [#to_s] the content of the rule
|
270
270
|
# @param private [Boolean]
|
271
271
|
def self.build(content, private: false)
|
272
|
-
new(value: content.to_s[1
|
272
|
+
new(value: content.to_s[1..], private: private)
|
273
273
|
end
|
274
274
|
|
275
275
|
# Gets the original rule definition.
|
@@ -299,7 +299,7 @@ module PublicSuffix
|
|
299
299
|
#
|
300
300
|
# @return [Array<String>]
|
301
301
|
def parts
|
302
|
-
@value.split(DOT)[1
|
302
|
+
@value.split(DOT)[1..]
|
303
303
|
end
|
304
304
|
|
305
305
|
end
|
data/lib/public_suffix.rb
CHANGED
@@ -169,7 +169,7 @@ module PublicSuffix
|
|
169
169
|
|
170
170
|
return DomainInvalid.new("Name is blank") if name.empty?
|
171
171
|
return DomainInvalid.new("Name starts with a dot") if name.start_with?(DOT)
|
172
|
-
return DomainInvalid.new("%s is not expected to contain a scheme"
|
172
|
+
return DomainInvalid.new(format("%s is not expected to contain a scheme", name)) if name.include?("://")
|
173
173
|
|
174
174
|
name
|
175
175
|
end
|
data/public_suffix.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"source_code_uri" => "https://github.com/weppos/publicsuffix-ruby/tree/v#{s.version}",
|
21
21
|
}
|
22
22
|
|
23
|
-
s.required_ruby_version = ">= 2.
|
23
|
+
s.required_ruby_version = ">= 2.6"
|
24
24
|
|
25
25
|
s.require_paths = ["lib"]
|
26
26
|
s.files = `git ls-files`.split("\n")
|
data/test/acceptance_test.rb
CHANGED
@@ -64,7 +64,7 @@ class AcceptanceTest < Minitest::Test
|
|
64
64
|
def test_rejected
|
65
65
|
REJECTED_CASES.each do |name, expected|
|
66
66
|
assert_equal expected, PublicSuffix.valid?(name),
|
67
|
-
"Expected %s to be %s"
|
67
|
+
format("Expected %s to be %s", name.inspect, expected.inspect)
|
68
68
|
assert !valid_domain?(name),
|
69
69
|
"#{name} expected to be invalid"
|
70
70
|
end
|
@@ -72,9 +72,9 @@ class AcceptanceTest < Minitest::Test
|
|
72
72
|
|
73
73
|
|
74
74
|
CASE_CASES = [
|
75
|
-
["Www.google.com", %w
|
76
|
-
["www.Google.com", %w
|
77
|
-
["www.google.Com", %w
|
75
|
+
["Www.google.com", %w[www google com]],
|
76
|
+
["www.Google.com", %w[www google com]],
|
77
|
+
["www.google.Com", %w[www google com]],
|
78
78
|
].freeze
|
79
79
|
|
80
80
|
def test_ignore_case
|
data/test/psl_test.rb
CHANGED
@@ -45,7 +45,7 @@ class PslTest < Minitest::Test
|
|
45
45
|
end
|
46
46
|
|
47
47
|
message = "The following #{failures.size} tests fail:\n"
|
48
|
-
failures.each { |i, o, d| message += "Expected %s to be %s, got %s\n"
|
48
|
+
failures.each { |i, o, d| message += format("Expected %s to be %s, got %s\n", i.inspect, o.inspect, d.inspect) }
|
49
49
|
assert_equal 0, failures.size, message
|
50
50
|
end
|
51
51
|
|
data/test/unit/domain_test.rb
CHANGED
@@ -10,15 +10,15 @@ class PublicSuffix::DomainTest < Minitest::Test
|
|
10
10
|
|
11
11
|
# Tokenizes given input into labels.
|
12
12
|
def test_self_name_to_labels
|
13
|
-
assert_equal %w
|
13
|
+
assert_equal %w[someone spaces live com],
|
14
14
|
PublicSuffix::Domain.name_to_labels("someone.spaces.live.com")
|
15
|
-
assert_equal %w
|
15
|
+
assert_equal %w[leontina23samiko wiki zoho com],
|
16
16
|
PublicSuffix::Domain.name_to_labels("leontina23samiko.wiki.zoho.com")
|
17
17
|
end
|
18
18
|
|
19
19
|
# Converts input into String.
|
20
20
|
def test_self_name_to_labels_converts_input_to_string
|
21
|
-
assert_equal %w
|
21
|
+
assert_equal %w[someone spaces live com],
|
22
22
|
PublicSuffix::Domain.name_to_labels(:"someone.spaces.live.com")
|
23
23
|
end
|
24
24
|
|
data/test/unit/list_test.rb
CHANGED
@@ -214,7 +214,7 @@ LIST
|
|
214
214
|
assert_instance_of PublicSuffix::List, list
|
215
215
|
assert_equal 4, list.size
|
216
216
|
|
217
|
-
rules = %w
|
217
|
+
rules = %w[com *.uk !british-library.uk blogspot.com].map { |name| PublicSuffix::Rule.factory(name) }
|
218
218
|
assert_equal rules, list.each.to_a
|
219
219
|
|
220
220
|
# private domains
|
data/test/unit/rule_test.rb
CHANGED
@@ -29,8 +29,8 @@ class PublicSuffix::RuleTest < Minitest::Test
|
|
29
29
|
def test_default_returns_default_wildcard
|
30
30
|
default = PublicSuffix::Rule.default
|
31
31
|
assert_equal PublicSuffix::Rule::Wildcard.build("*"), default
|
32
|
-
assert_equal %w
|
33
|
-
assert_equal %w
|
32
|
+
assert_equal %w[example tldnotlisted], default.decompose("example.tldnotlisted")
|
33
|
+
assert_equal %w[www.example tldnotlisted], default.decompose("www.example.tldnotlisted")
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -140,15 +140,15 @@ class PublicSuffix::RuleNormalTest < Minitest::Test
|
|
140
140
|
end
|
141
141
|
|
142
142
|
def test_parts
|
143
|
-
assert_equal %w
|
144
|
-
assert_equal %w
|
145
|
-
assert_equal %w
|
143
|
+
assert_equal %w[com], @klass.build("com").parts
|
144
|
+
assert_equal %w[co com], @klass.build("co.com").parts
|
145
|
+
assert_equal %w[mx co com], @klass.build("mx.co.com").parts
|
146
146
|
end
|
147
147
|
|
148
148
|
def test_decompose
|
149
149
|
assert_equal [nil, nil], @klass.build("com").decompose("com")
|
150
|
-
assert_equal %w
|
151
|
-
assert_equal %w
|
150
|
+
assert_equal %w[example com], @klass.build("com").decompose("example.com")
|
151
|
+
assert_equal %w[foo.example com], @klass.build("com").decompose("foo.example.com")
|
152
152
|
end
|
153
153
|
|
154
154
|
end
|
@@ -175,14 +175,14 @@ class PublicSuffix::RuleExceptionTest < Minitest::Test
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def test_parts
|
178
|
-
assert_equal %w
|
179
|
-
assert_equal %w
|
178
|
+
assert_equal %w[uk], @klass.build("!british-library.uk").parts
|
179
|
+
assert_equal %w[tokyo jp], @klass.build("!metro.tokyo.jp").parts
|
180
180
|
end
|
181
181
|
|
182
182
|
def test_decompose
|
183
183
|
assert_equal [nil, nil], @klass.build("!british-library.uk").decompose("uk")
|
184
|
-
assert_equal %w
|
185
|
-
assert_equal %w
|
184
|
+
assert_equal %w[british-library uk], @klass.build("!british-library.uk").decompose("british-library.uk")
|
185
|
+
assert_equal %w[foo.british-library uk], @klass.build("!british-library.uk").decompose("foo.british-library.uk")
|
186
186
|
end
|
187
187
|
|
188
188
|
end
|
@@ -209,14 +209,14 @@ class PublicSuffix::RuleWildcardTest < Minitest::Test
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def test_parts
|
212
|
-
assert_equal %w
|
213
|
-
assert_equal %w
|
212
|
+
assert_equal %w[uk], @klass.build("*.uk").parts
|
213
|
+
assert_equal %w[co uk], @klass.build("*.co.uk").parts
|
214
214
|
end
|
215
215
|
|
216
216
|
def test_decompose
|
217
217
|
assert_equal [nil, nil], @klass.build("*.do").decompose("nic.do")
|
218
|
-
assert_equal %w
|
219
|
-
assert_equal %w
|
218
|
+
assert_equal %w[google co.uk], @klass.build("*.uk").decompose("google.co.uk")
|
219
|
+
assert_equal %w[foo.google co.uk], @klass.build("*.uk").decompose("foo.google.co.uk")
|
220
220
|
end
|
221
221
|
|
222
222
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_suffix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Carletti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: PublicSuffix can parse and decompose a domain name into top level domain,
|
14
14
|
domain and subdomains.
|
@@ -21,6 +21,7 @@ extra_rdoc_files:
|
|
21
21
|
files:
|
22
22
|
- ".github/FUNDING.yml"
|
23
23
|
- ".github/dependabot.yml"
|
24
|
+
- ".github/workflows/psl-update.yml"
|
24
25
|
- ".github/workflows/release.yml"
|
25
26
|
- ".github/workflows/tests.yml"
|
26
27
|
- ".gitignore"
|
@@ -71,9 +72,9 @@ licenses:
|
|
71
72
|
metadata:
|
72
73
|
bug_tracker_uri: https://github.com/weppos/publicsuffix-ruby/issues
|
73
74
|
changelog_uri: https://github.com/weppos/publicsuffix-ruby/blob/master/CHANGELOG.md
|
74
|
-
documentation_uri: https://rubydoc.info/gems/public_suffix/
|
75
|
+
documentation_uri: https://rubydoc.info/gems/public_suffix/5.0.1
|
75
76
|
homepage_uri: https://simonecarletti.com/code/publicsuffix-ruby
|
76
|
-
source_code_uri: https://github.com/weppos/publicsuffix-ruby/tree/
|
77
|
+
source_code_uri: https://github.com/weppos/publicsuffix-ruby/tree/v5.0.1
|
77
78
|
post_install_message:
|
78
79
|
rdoc_options: []
|
79
80
|
require_paths:
|
@@ -82,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
83
|
requirements:
|
83
84
|
- - ">="
|
84
85
|
- !ruby/object:Gem::Version
|
85
|
-
version: '2.
|
86
|
+
version: '2.6'
|
86
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
88
|
requirements:
|
88
89
|
- - ">="
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
|
-
rubygems_version: 3.3.
|
93
|
+
rubygems_version: 3.3.26
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Domain name parser based on the Public Suffix List.
|