public_suffix 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/{LICENSE → LICENSE.txt} +2 -2
- data/README.md +6 -6
- data/lib/public_suffix.rb +4 -4
- data/lib/public_suffix/definitions.txt +101 -21
- data/lib/public_suffix/list.rb +2 -0
- data/lib/public_suffix/version.rb +2 -2
- data/public_suffix.gemspec +3 -3
- data/test/acceptance_test.rb +8 -5
- data/test/unit/list_test.rb +9 -0
- data/test/unit/public_suffix_test.rb +10 -0
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
|
4
|
+
## Release 1.2.0
|
5
|
+
|
6
|
+
- NEW: Allow a custom List on `PublicSuffix.parse` (GH-26). [Thanks @itspriddle]
|
7
|
+
|
8
|
+
- FIXED: PublicSuffix.parse and PublicSuffix.valid? crashes when input is nil (GH-20).
|
9
|
+
|
10
|
+
- CHANGED: Updated definitions.
|
11
|
+
|
12
|
+
|
4
13
|
## Release 1.1.3
|
5
14
|
|
6
15
|
- CHANGED: Updated definitions.
|
data/{LICENSE → LICENSE.txt}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
1
|
Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
|
4
2
|
|
3
|
+
MIT License
|
4
|
+
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
7
7
|
"Software"), to deal in the Software without restriction, including
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
*PublicSuffix* is a Ruby domain name parser based on the [Public Suffix List](http://publicsuffix.org/).
|
4
4
|
|
5
|
-
[![Build Status](https://secure.travis-ci.org/weppos/
|
5
|
+
[![Build Status](https://secure.travis-ci.org/weppos/publicsuffix-ruby.png)](http://travis-ci.org/weppos/publicsuffix-ruby)
|
6
6
|
|
7
7
|
|
8
8
|
## What is the Public Suffix List?
|
@@ -35,9 +35,9 @@ Not convinced yet? Check out [this real world example](http://stackoverflow.com/
|
|
35
35
|
|
36
36
|
- Ruby >= 1.8.7
|
37
37
|
|
38
|
-
*PublicSuffix* requires Ruby 1.8.7 or greater. For older versions of Ruby, see the CHANGELOG.md file.
|
38
|
+
*PublicSuffix* requires Ruby 1.8.7 or greater. For older versions of Ruby, see the [CHANGELOG.md](CHANGELOG.md) file.
|
39
39
|
|
40
|
-
We also support several [Ruby implementations](http://www.simonecarletti.com/code/
|
40
|
+
We also support several [Ruby implementations](http://www.simonecarletti.com/code/publicsuffix/#implementations).
|
41
41
|
|
42
42
|
|
43
43
|
## Installation
|
@@ -115,13 +115,13 @@ If you use this library and find yourself missing any functionality, please [let
|
|
115
115
|
|
116
116
|
Pull requests are very welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.
|
117
117
|
|
118
|
-
Report issues or feature requests to [GitHub Issues](https://github.com/weppos/
|
118
|
+
Report issues or feature requests to [GitHub Issues](https://github.com/weppos/publicsuffix-ruby/issues).
|
119
119
|
|
120
120
|
|
121
121
|
## More
|
122
122
|
|
123
|
-
* [Homepage](http://www.simonecarletti.com/code/
|
124
|
-
* [Repository](https://github.com/weppos/
|
123
|
+
* [Homepage](http://www.simonecarletti.com/code/publicsuffix)
|
124
|
+
* [Repository](https://github.com/weppos/publicsuffix-ruby)
|
125
125
|
* [API Documentation](http://rubydoc.info/gems/public_suffix)
|
126
126
|
* [Introducing the Public Suffix List library for Ruby](http://www.simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/)
|
127
127
|
|
data/lib/public_suffix.rb
CHANGED
@@ -24,10 +24,10 @@ module PublicSuffix
|
|
24
24
|
# Parses +domain+ and returns the
|
25
25
|
# {PublicSuffix::Domain} instance.
|
26
26
|
#
|
27
|
-
# Parsing uses the default {PublicSuffix::List}.
|
28
|
-
#
|
29
27
|
# @param [String, #to_s] domain
|
30
28
|
# The domain name or fully qualified domain name to parse.
|
29
|
+
# @param [PublicSuffix::List] list
|
30
|
+
# The rule list to search, defaults to the default {PublicSuffix::List}
|
31
31
|
#
|
32
32
|
# @return [PublicSuffix::Domain]
|
33
33
|
#
|
@@ -61,8 +61,8 @@ module PublicSuffix
|
|
61
61
|
# If a rule for +domain+ is found, but the rule
|
62
62
|
# doesn't allow +domain+.
|
63
63
|
#
|
64
|
-
def self.parse(domain)
|
65
|
-
rule =
|
64
|
+
def self.parse(domain, list = List.default)
|
65
|
+
rule = list.find(domain)
|
66
66
|
|
67
67
|
if rule.nil?
|
68
68
|
raise DomainInvalid, "`#{domain}' is not a valid domain"
|
@@ -219,7 +219,6 @@ net.au
|
|
219
219
|
org.au
|
220
220
|
edu.au
|
221
221
|
gov.au
|
222
|
-
csiro.au
|
223
222
|
asn.au
|
224
223
|
id.au
|
225
224
|
// Historic 2LDs (closed to new registration, but sites still exist)
|
@@ -950,9 +949,15 @@ gov.gr
|
|
950
949
|
// gs : http://en.wikipedia.org/wiki/.gs
|
951
950
|
gs
|
952
951
|
|
953
|
-
// gt : http://www.gt/
|
954
|
-
|
955
|
-
|
952
|
+
// gt : http://www.gt/politicas_de_registro.html
|
953
|
+
gt
|
954
|
+
com.gt
|
955
|
+
edu.gt
|
956
|
+
gob.gt
|
957
|
+
ind.gt
|
958
|
+
mil.gt
|
959
|
+
net.gt
|
960
|
+
org.gt
|
956
961
|
|
957
962
|
// gu : http://gadao.gov.gu/registration.txt
|
958
963
|
*.gu
|
@@ -4166,6 +4171,7 @@ name.my
|
|
4166
4171
|
|
4167
4172
|
// mz : http://www.gobin.info/domainname/mz-template.doc
|
4168
4173
|
*.mz
|
4174
|
+
!teledata.mz
|
4169
4175
|
|
4170
4176
|
// na : http://www.na-nic.com.na/
|
4171
4177
|
// http://www.info.na/domain/
|
@@ -5359,8 +5365,16 @@ ed.pw
|
|
5359
5365
|
go.pw
|
5360
5366
|
belau.pw
|
5361
5367
|
|
5362
|
-
// py : http://www.nic.py/
|
5363
|
-
|
5368
|
+
// py : http://www.nic.py/pautas.html#seccion_9
|
5369
|
+
// Confirmed by registry 2012-10-03
|
5370
|
+
py
|
5371
|
+
com.py
|
5372
|
+
coop.py
|
5373
|
+
edu.py
|
5374
|
+
gov.py
|
5375
|
+
mil.py
|
5376
|
+
net.py
|
5377
|
+
org.py
|
5364
5378
|
|
5365
5379
|
// qa : http://domains.qa/en/
|
5366
5380
|
qa
|
@@ -5999,20 +6013,19 @@ com.ug
|
|
5999
6013
|
org.ug
|
6000
6014
|
|
6001
6015
|
// uk : http://en.wikipedia.org/wiki/.uk
|
6016
|
+
// Submitted by registry <noc@nominet.org.uk> 2012-10-02
|
6017
|
+
// and tweaked by us pending further consultation.
|
6002
6018
|
*.uk
|
6003
6019
|
*.sch.uk
|
6004
6020
|
!bl.uk
|
6005
6021
|
!british-library.uk
|
6006
|
-
!icnet.uk
|
6007
6022
|
!jet.uk
|
6008
6023
|
!mod.uk
|
6024
|
+
!national-library-scotland.uk
|
6009
6025
|
!nel.uk
|
6010
|
-
!nhs.uk
|
6011
6026
|
!nic.uk
|
6012
6027
|
!nls.uk
|
6013
|
-
!national-library-scotland.uk
|
6014
6028
|
!parliament.uk
|
6015
|
-
!police.uk
|
6016
6029
|
|
6017
6030
|
// us : http://en.wikipedia.org/wiki/.us
|
6018
6031
|
us
|
@@ -6288,8 +6301,19 @@ gov.vc
|
|
6288
6301
|
mil.vc
|
6289
6302
|
edu.vc
|
6290
6303
|
|
6291
|
-
// ve :
|
6292
|
-
|
6304
|
+
// ve : https://registro.nic.ve/
|
6305
|
+
// Confirmed by registry 2012-10-04
|
6306
|
+
ve
|
6307
|
+
co.ve
|
6308
|
+
com.ve
|
6309
|
+
e12.ve
|
6310
|
+
edu.ve
|
6311
|
+
gov.ve
|
6312
|
+
info.ve
|
6313
|
+
mil.ve
|
6314
|
+
net.ve
|
6315
|
+
org.ve
|
6316
|
+
web.ve
|
6293
6317
|
|
6294
6318
|
// vg : http://en.wikipedia.org/wiki/.vg
|
6295
6319
|
vg
|
@@ -6529,15 +6553,20 @@ priv.at
|
|
6529
6553
|
co.ca
|
6530
6554
|
|
6531
6555
|
// CentralNic : http://www.centralnic.com/names/domains
|
6532
|
-
// Confirmed by registry <gavin.brown@centralnic.com>
|
6556
|
+
// Confirmed by registry <gavin.brown@centralnic.com> 2012-09-27
|
6557
|
+
ae.org
|
6533
6558
|
ar.com
|
6534
6559
|
br.com
|
6535
6560
|
cn.com
|
6561
|
+
com.de
|
6536
6562
|
de.com
|
6537
6563
|
eu.com
|
6538
6564
|
gb.com
|
6565
|
+
gb.net
|
6539
6566
|
gr.com
|
6540
6567
|
hu.com
|
6568
|
+
hu.net
|
6569
|
+
jp.net
|
6541
6570
|
jpn.com
|
6542
6571
|
kr.com
|
6543
6572
|
no.com
|
@@ -6545,25 +6574,68 @@ qc.com
|
|
6545
6574
|
ru.com
|
6546
6575
|
sa.com
|
6547
6576
|
se.com
|
6577
|
+
se.net
|
6548
6578
|
uk.com
|
6579
|
+
uk.net
|
6549
6580
|
us.com
|
6581
|
+
us.org
|
6550
6582
|
uy.com
|
6551
6583
|
za.com
|
6552
|
-
gb.net
|
6553
|
-
jp.net
|
6554
|
-
se.net
|
6555
|
-
uk.net
|
6556
|
-
ae.org
|
6557
|
-
us.org
|
6558
|
-
com.de
|
6559
6584
|
|
6560
6585
|
// Opera Software, A.S.A.
|
6561
6586
|
// Requested by Yngve Pettersen <yngve@opera.com> 2009-11-26
|
6562
6587
|
operaunite.com
|
6563
6588
|
|
6564
6589
|
// Google, Inc.
|
6565
|
-
// Requested by Eduardo Vela <evn@google.com>
|
6590
|
+
// Requested by Eduardo Vela <evn@google.com> 2012-10-24
|
6566
6591
|
appspot.com
|
6592
|
+
blogspot.be
|
6593
|
+
blogspot.bj
|
6594
|
+
blogspot.ca
|
6595
|
+
blogspot.cf
|
6596
|
+
blogspot.ch
|
6597
|
+
blogspot.co.at
|
6598
|
+
blogspot.co.il
|
6599
|
+
blogspot.co.nz
|
6600
|
+
blogspot.co.uk
|
6601
|
+
blogspot.com
|
6602
|
+
blogspot.com.ar
|
6603
|
+
blogspot.com.au
|
6604
|
+
blogspot.com.br
|
6605
|
+
blogspot.com.es
|
6606
|
+
blogspot.cv
|
6607
|
+
blogspot.cz
|
6608
|
+
blogspot.de
|
6609
|
+
blogspot.dk
|
6610
|
+
blogspot.fi
|
6611
|
+
blogspot.fr
|
6612
|
+
blogspot.gr
|
6613
|
+
blogspot.hk
|
6614
|
+
blogspot.hu
|
6615
|
+
blogspot.ie
|
6616
|
+
blogspot.in
|
6617
|
+
blogspot.it
|
6618
|
+
blogspot.jp
|
6619
|
+
blogspot.kr
|
6620
|
+
blogspot.mr
|
6621
|
+
blogspot.mx
|
6622
|
+
blogspot.nl
|
6623
|
+
blogspot.no
|
6624
|
+
blogspot.pt
|
6625
|
+
blogspot.re
|
6626
|
+
blogspot.ro
|
6627
|
+
blogspot.se
|
6628
|
+
blogspot.sg
|
6629
|
+
blogspot.sk
|
6630
|
+
blogspot.td
|
6631
|
+
blogspot.tw
|
6632
|
+
codespot.com
|
6633
|
+
googleapis.com
|
6634
|
+
googlecode.com
|
6635
|
+
|
6636
|
+
// DreamHost : http://www.dreamhost.com/
|
6637
|
+
// Requested by Andrew Farmer <andrew.farmer@dreamhost.com> 2012-10-02
|
6638
|
+
dreamhosters.com
|
6567
6639
|
|
6568
6640
|
// iki.fi : Submitted by Hannu Aronsson <haa@iki.fi> 2009-11-05
|
6569
6641
|
iki.fi
|
@@ -6865,4 +6937,12 @@ webhop.org
|
|
6865
6937
|
worse-than.tv
|
6866
6938
|
writesthisblog.com
|
6867
6939
|
|
6940
|
+
// BetaInABox
|
6941
|
+
// Requested by adrian@betainabox.com 2012-09-13
|
6942
|
+
betainabox.com
|
6943
|
+
|
6944
|
+
// Red Hat, Inc. OpenShift : https://openshift.redhat.com/
|
6945
|
+
// Requested by Tim Kramer <tkramer@rhcloud.com> 2012-10-24
|
6946
|
+
rhcloud.com
|
6947
|
+
|
6868
6948
|
// ===END PRIVATE DOMAINS===
|
data/lib/public_suffix/list.rb
CHANGED
@@ -272,6 +272,8 @@ module PublicSuffix
|
|
272
272
|
#
|
273
273
|
# @return [Array<PublicSuffix::Rule::*>]
|
274
274
|
def select(domain)
|
275
|
+
# raise DomainInvalid, "Blank domain"
|
276
|
+
return [] if domain.to_s !~ /[^[:space:]]/
|
275
277
|
# raise DomainInvalid, "`#{domain}' is not expected to contain a scheme"
|
276
278
|
return [] if domain.include?("://")
|
277
279
|
|
data/public_suffix.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "public_suffix"
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Simone Carletti"]
|
9
|
-
s.date = "2012-
|
9
|
+
s.date = "2012-12-24"
|
10
10
|
s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
|
11
11
|
s.email = "weppos@weppos.net"
|
12
|
-
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG.md", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/public_suffix.rb", "lib/public_suffix/definitions.txt", "lib/public_suffix/domain.rb", "lib/public_suffix/errors.rb", "lib/public_suffix/list.rb", "lib/public_suffix/rule.rb", "lib/public_suffix/version.rb", "public_suffix.gemspec", "test/acceptance_test.rb", "test/test_helper.rb", "test/unit/domain_test.rb", "test/unit/errors_test.rb", "test/unit/list_test.rb", "test/unit/public_suffix_test.rb", "test/unit/rule_test.rb"]
|
12
|
+
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/public_suffix.rb", "lib/public_suffix/definitions.txt", "lib/public_suffix/domain.rb", "lib/public_suffix/errors.rb", "lib/public_suffix/list.rb", "lib/public_suffix/rule.rb", "lib/public_suffix/version.rb", "public_suffix.gemspec", "test/acceptance_test.rb", "test/test_helper.rb", "test/unit/domain_test.rb", "test/unit/errors_test.rb", "test/unit/list_test.rb", "test/unit/public_suffix_test.rb", "test/unit/rule_test.rb"]
|
13
13
|
s.homepage = "http://www.simonecarletti.com/code/public_suffix"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
data/test/acceptance_test.rb
CHANGED
@@ -24,13 +24,16 @@ class AcceptanceTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
InvalidCases =
|
28
|
-
"nic.ke"
|
29
|
-
"http://www.google.com"
|
30
|
-
|
27
|
+
InvalidCases = [
|
28
|
+
["nic.ke", PublicSuffix::DomainNotAllowed],
|
29
|
+
["http://www.google.com", PublicSuffix::DomainInvalid],
|
30
|
+
[nil, PublicSuffix::DomainInvalid],
|
31
|
+
["", PublicSuffix::DomainInvalid],
|
32
|
+
[" ", PublicSuffix::DomainInvalid],
|
33
|
+
]
|
31
34
|
|
32
35
|
def test_invalid
|
33
|
-
InvalidCases.each do |name, error|
|
36
|
+
InvalidCases.each do |(name, error)|
|
34
37
|
assert_raise(error) { PublicSuffix.parse(name) }
|
35
38
|
assert !PublicSuffix.valid?(name)
|
36
39
|
end
|
data/test/unit/list_test.rb
CHANGED
@@ -95,6 +95,15 @@ class PublicSuffix::ListTest < Test::Unit::TestCase
|
|
95
95
|
assert_not_equal [], list.select("google.com")
|
96
96
|
end
|
97
97
|
|
98
|
+
def test_select_returns_empty_when_domain_is_nil
|
99
|
+
assert_equal [], list.select(nil)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_select_returns_empty_when_domain_is_blank
|
103
|
+
assert_equal [], list.select("")
|
104
|
+
assert_equal [], list.select(" ")
|
105
|
+
end
|
106
|
+
|
98
107
|
|
99
108
|
def test_self_default_getter
|
100
109
|
assert_equal nil, PublicSuffix::List.class_eval { @default }
|
@@ -52,6 +52,16 @@ class PublicSuffixTest < Test::Unit::TestCase
|
|
52
52
|
assert_equal "www", domain.trd
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_self_parse_a_domain_with_custom_list
|
56
|
+
list = PublicSuffix::List.new
|
57
|
+
list << PublicSuffix::Rule.factory("test")
|
58
|
+
|
59
|
+
domain = PublicSuffix.parse("www.example.test", list)
|
60
|
+
assert_equal "test", domain.tld
|
61
|
+
assert_equal "example", domain.sld
|
62
|
+
assert_equal "www", domain.trd
|
63
|
+
end
|
64
|
+
|
55
65
|
def test_self_parse_raises_with_invalid_domain
|
56
66
|
error = assert_raise(PublicSuffix::DomainInvalid) { PublicSuffix.parse("example.zip") }
|
57
67
|
assert_match %r{example\.zip}, error.message
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: public_suffix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- .yardopts
|
73
73
|
- CHANGELOG.md
|
74
74
|
- Gemfile
|
75
|
-
- LICENSE
|
75
|
+
- LICENSE.txt
|
76
76
|
- README.md
|
77
77
|
- Rakefile
|
78
78
|
- lib/public_suffix.rb
|