domain_name 0.5.4 → 0.5.5
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.
- data/lib/domain_name.rb +10 -3
- data/lib/domain_name/version.rb +1 -1
- data/test/test_domain_name.rb +75 -33
- metadata +11 -31
data/lib/domain_name.rb
CHANGED
|
@@ -125,9 +125,16 @@ class DomainName
|
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
# Checks if the server represented by
|
|
129
|
-
# and receive cookies
|
|
130
|
-
|
|
128
|
+
# Checks if the server represented by this domain is qualified to
|
|
129
|
+
# send and receive cookies with a domain attribute value of
|
|
130
|
+
# _domain_. A true value given as the second argument represents
|
|
131
|
+
# cookies without a domain attribute value, in which case only
|
|
132
|
+
# hostname equality is checked.
|
|
133
|
+
def cookie_domain?(domain, host_only = false)
|
|
134
|
+
# RFC 6265 #5.3
|
|
135
|
+
# When the user agent "receives a cookie":
|
|
136
|
+
return self == domain if host_only
|
|
137
|
+
|
|
131
138
|
domain = DomainName.new(domain) unless DomainName === domain
|
|
132
139
|
if ipaddr?
|
|
133
140
|
# RFC 6265 #5.1.3
|
data/lib/domain_name/version.rb
CHANGED
data/test/test_domain_name.rb
CHANGED
|
@@ -160,40 +160,77 @@ class TestDomainName < Test::Unit::TestCase
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
should "check cookie domain correctly" do
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
163
|
+
{
|
|
164
|
+
'com' => [
|
|
165
|
+
['com', false],
|
|
166
|
+
['example.com', false],
|
|
167
|
+
['foo.example.com', false],
|
|
168
|
+
['bar.foo.example.com', false],
|
|
169
|
+
],
|
|
170
|
+
|
|
171
|
+
'example.com' => [
|
|
172
|
+
['com', false],
|
|
173
|
+
['example.com', true],
|
|
174
|
+
['foo.example.com', false],
|
|
175
|
+
['bar.foo.example.com', false],
|
|
176
|
+
],
|
|
177
|
+
|
|
178
|
+
'foo.example.com' => [
|
|
179
|
+
['com', false],
|
|
180
|
+
['example.com', true],
|
|
181
|
+
['foo.example.com', true],
|
|
182
|
+
['foo.Example.com', true],
|
|
183
|
+
['bar.foo.example.com', false],
|
|
184
|
+
['bar.Foo.Example.com', false],
|
|
185
|
+
],
|
|
186
|
+
|
|
187
|
+
'b.sapporo.jp' => [
|
|
188
|
+
['jp', false],
|
|
189
|
+
['sapporo.jp', false],
|
|
190
|
+
['b.sapporo.jp', false],
|
|
191
|
+
['a.b.sapporo.jp', false],
|
|
192
|
+
],
|
|
193
|
+
|
|
194
|
+
'b.c.sapporo.jp' => [
|
|
195
|
+
['jp', false],
|
|
196
|
+
['sapporo.jp', false],
|
|
197
|
+
['c.sapporo.jp', false],
|
|
198
|
+
['b.c.sapporo.jp', true],
|
|
199
|
+
['a.b.c.sapporo.jp', false],
|
|
200
|
+
],
|
|
201
|
+
|
|
202
|
+
'b.c.d.sapporo.jp' => [
|
|
203
|
+
['jp', false],
|
|
204
|
+
['sapporo.jp', false],
|
|
205
|
+
['d.sapporo.jp', false],
|
|
206
|
+
['c.d.sapporo.jp', true],
|
|
207
|
+
['b.c.d.sapporo.jp', true],
|
|
208
|
+
['a.b.c.d.sapporo.jp', false],
|
|
209
|
+
],
|
|
210
|
+
|
|
211
|
+
'city.sapporo.jp' => [
|
|
212
|
+
['jp', false],
|
|
213
|
+
['sapporo.jp', false],
|
|
214
|
+
['city.sapporo.jp', true],
|
|
215
|
+
['a.city.sapporo.jp', false],
|
|
216
|
+
],
|
|
217
|
+
|
|
218
|
+
'b.city.sapporo.jp' => [
|
|
219
|
+
['jp', false],
|
|
220
|
+
['sapporo.jp', false],
|
|
221
|
+
['city.sapporo.jp', true],
|
|
222
|
+
['b.city.sapporo.jp', true],
|
|
223
|
+
['a.b.city.sapporo.jp', false],
|
|
224
|
+
],
|
|
225
|
+
}.each_pair { |host, pairs|
|
|
193
226
|
dn = DomainName(host)
|
|
194
|
-
assert_equal(
|
|
195
|
-
assert_equal(
|
|
196
|
-
assert_equal(false, dn.
|
|
227
|
+
assert_equal(true, dn.cookie_domain?(host.upcase, true), dn.to_s)
|
|
228
|
+
assert_equal(true, dn.cookie_domain?(host.downcase, true), dn.to_s)
|
|
229
|
+
assert_equal(false, dn.cookie_domain?("www." << host, true), dn.to_s)
|
|
230
|
+
pairs.each { |domain, expected|
|
|
231
|
+
assert_equal(expected, dn.cookie_domain?(domain), "%s - %s" % [dn.to_s, domain])
|
|
232
|
+
assert_equal(expected, dn.cookie_domain?(DomainName(domain)), "%s - %s" % [dn.to_s, domain])
|
|
233
|
+
}
|
|
197
234
|
}
|
|
198
235
|
end
|
|
199
236
|
|
|
@@ -204,7 +241,9 @@ class TestDomainName < Test::Unit::TestCase
|
|
|
204
241
|
assert_equal(true, dn.ipaddr?)
|
|
205
242
|
assert_equal(IPAddr.new(a), dn.ipaddr)
|
|
206
243
|
assert_equal(true, dn.cookie_domain?(a))
|
|
244
|
+
assert_equal(true, dn.cookie_domain?(a, true))
|
|
207
245
|
assert_equal(true, dn.cookie_domain?(dn))
|
|
246
|
+
assert_equal(true, dn.cookie_domain?(dn, true))
|
|
208
247
|
assert_equal(false, dn.cookie_domain?('168.10.20'))
|
|
209
248
|
assert_equal(false, dn.cookie_domain?('20'))
|
|
210
249
|
end
|
|
@@ -219,8 +258,11 @@ class TestDomainName < Test::Unit::TestCase
|
|
|
219
258
|
assert_equal(true, dn.ipaddr?)
|
|
220
259
|
assert_equal(IPAddr.new(a), dn.ipaddr)
|
|
221
260
|
assert_equal(true, dn.cookie_domain?(host))
|
|
261
|
+
assert_equal(true, dn.cookie_domain?(host, true))
|
|
222
262
|
assert_equal(true, dn.cookie_domain?(dn))
|
|
263
|
+
assert_equal(true, dn.cookie_domain?(dn, true))
|
|
223
264
|
assert_equal(true, dn.cookie_domain?(a))
|
|
265
|
+
assert_equal(true, dn.cookie_domain?(a, true))
|
|
224
266
|
}
|
|
225
267
|
end
|
|
226
268
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: domain_name
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.5
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: unf
|
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirement: &70293817315960 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,15 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 0.0.3
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
25
|
-
none: false
|
|
26
|
-
requirements:
|
|
27
|
-
- - ~>
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.0.3
|
|
24
|
+
version_requirements: *70293817315960
|
|
30
25
|
- !ruby/object:Gem::Dependency
|
|
31
26
|
name: shoulda
|
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
|
27
|
+
requirement: &70293817314640 !ruby/object:Gem::Requirement
|
|
33
28
|
none: false
|
|
34
29
|
requirements:
|
|
35
30
|
- - ! '>='
|
|
@@ -37,15 +32,10 @@ dependencies:
|
|
|
37
32
|
version: '0'
|
|
38
33
|
type: :development
|
|
39
34
|
prerelease: false
|
|
40
|
-
version_requirements:
|
|
41
|
-
none: false
|
|
42
|
-
requirements:
|
|
43
|
-
- - ! '>='
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
version: '0'
|
|
35
|
+
version_requirements: *70293817314640
|
|
46
36
|
- !ruby/object:Gem::Dependency
|
|
47
37
|
name: bundler
|
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
|
38
|
+
requirement: &70293817313160 !ruby/object:Gem::Requirement
|
|
49
39
|
none: false
|
|
50
40
|
requirements:
|
|
51
41
|
- - ~>
|
|
@@ -53,15 +43,10 @@ dependencies:
|
|
|
53
43
|
version: 1.2.0
|
|
54
44
|
type: :development
|
|
55
45
|
prerelease: false
|
|
56
|
-
version_requirements:
|
|
57
|
-
none: false
|
|
58
|
-
requirements:
|
|
59
|
-
- - ~>
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.2.0
|
|
46
|
+
version_requirements: *70293817313160
|
|
62
47
|
- !ruby/object:Gem::Dependency
|
|
63
48
|
name: rdoc
|
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
requirement: &70293817312260 !ruby/object:Gem::Requirement
|
|
65
50
|
none: false
|
|
66
51
|
requirements:
|
|
67
52
|
- - ! '>='
|
|
@@ -69,12 +54,7 @@ dependencies:
|
|
|
69
54
|
version: 2.4.2
|
|
70
55
|
type: :development
|
|
71
56
|
prerelease: false
|
|
72
|
-
version_requirements:
|
|
73
|
-
none: false
|
|
74
|
-
requirements:
|
|
75
|
-
- - ! '>='
|
|
76
|
-
- !ruby/object:Gem::Version
|
|
77
|
-
version: 2.4.2
|
|
57
|
+
version_requirements: *70293817312260
|
|
78
58
|
description: ! 'This is a Domain Name manipulation library for Ruby.
|
|
79
59
|
|
|
80
60
|
|
|
@@ -129,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
109
|
version: '0'
|
|
130
110
|
requirements: []
|
|
131
111
|
rubyforge_project:
|
|
132
|
-
rubygems_version: 1.8.
|
|
112
|
+
rubygems_version: 1.8.15
|
|
133
113
|
signing_key:
|
|
134
114
|
specification_version: 3
|
|
135
115
|
summary: Domain Name manipulation library for Ruby
|