public-suffix-list 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/public_suffix_list.rb +5 -2
- data/spec/public_suffix_list_spec.rb +14 -0
- data/spec/test.dat +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e07ccdd8cb5bc94567fa0a93437e7c8cabd66a671d31d0a06030ec49aff9481f
|
4
|
+
data.tar.gz: 3a2ec9b5966283c4d11c4c1121109af701acb71331807b67aa45130c196da711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a154df3dc9285612da36dfc1ec38b98fd6ed1697f473d50692275bbbe5e2285101bc0973097ce9c0d96b124eb8eb525fef3f6141399626b3e206647926ed0f15
|
7
|
+
data.tar.gz: 7d2bdcb047214593da9ad91479f678247bd2467ff46bbd5d6df72e2da8af63a440010210e400f15af0725ba1843d04f37885c87a85368638497a4e317c35f860
|
data/lib/public_suffix_list.rb
CHANGED
@@ -6,7 +6,7 @@ require "public_suffix_list/parser.rb"
|
|
6
6
|
|
7
7
|
class PublicSuffixList
|
8
8
|
|
9
|
-
VERSION = "0.2.
|
9
|
+
VERSION = "0.2.1"
|
10
10
|
|
11
11
|
def self.config
|
12
12
|
@@config ||= Config.new
|
@@ -58,18 +58,21 @@ class PublicSuffixList
|
|
58
58
|
def split(domain)
|
59
59
|
domain = domain.split(".")
|
60
60
|
result = best(match(domain, rules, true))
|
61
|
+
return ["", "", ""] if result.empty?
|
61
62
|
[gimme!(domain, result.size), gimme!(domain), domain].reverse.map { |d| d ? d.join(".") : "" }
|
62
63
|
end
|
63
64
|
|
64
65
|
def tld(domain)
|
65
66
|
domain = domain.split(".")
|
66
67
|
result = best(match(domain, rules, true))
|
68
|
+
return "" if result.empty?
|
67
69
|
gimme!(domain, result.size).join(".")
|
68
70
|
end
|
69
71
|
|
70
72
|
def cdn(domain)
|
71
73
|
domain = domain.split(".")
|
72
74
|
result = best(match(domain, rules, true))
|
75
|
+
return "" if result.empty?
|
73
76
|
gimme!(domain, result.size + 1).join(".")
|
74
77
|
end
|
75
78
|
|
@@ -100,7 +103,7 @@ class PublicSuffixList
|
|
100
103
|
end
|
101
104
|
end
|
102
105
|
if wildcard
|
103
|
-
set << [
|
106
|
+
set << [first]
|
104
107
|
end
|
105
108
|
set
|
106
109
|
end
|
@@ -8,6 +8,20 @@ describe PublicSuffixList do
|
|
8
8
|
public_suffix_list.split("www.home.foobar").should == ["www", "home", "foobar"]
|
9
9
|
public_suffix_list.cdn("www.home.foobar").should == "home.foobar"
|
10
10
|
public_suffix_list.tld("www.home.foobar").should == "foobar"
|
11
|
+
public_suffix_list.split("foobar").should == ["", "", "foobar"]
|
12
|
+
public_suffix_list.cdn("foobar").should == ""
|
13
|
+
public_suffix_list.tld("foobar").should == "foobar"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should handle wildcard domains" do
|
17
|
+
public_suffix_list = PublicSuffixList.new(:url => "spec/test.dat")
|
18
|
+
public_suffix_list.cache_file.should be nil
|
19
|
+
public_suffix_list.split("mm").should == ["", "", ""]
|
20
|
+
public_suffix_list.cdn("mm").should == ""
|
21
|
+
public_suffix_list.tld("mm").should == ""
|
22
|
+
public_suffix_list.split("c.mm").should == ["", "", "c.mm"]
|
23
|
+
public_suffix_list.cdn("c.mm").should == ""
|
24
|
+
public_suffix_list.tld("c.mm").should == "c.mm"
|
11
25
|
end
|
12
26
|
|
13
27
|
it "should calculate tld and cdn correctly" do
|
data/spec/test.dat
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public-suffix-list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Sundsted
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Public Suffix List (http://publicsuffix.org/) is "a cross-vendor
|
14
14
|
initiative to provide an accurate list of domain name suffixes". Such a list is
|