addressable 2.5.0 → 2.8.8
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 +5 -5
- data/CHANGELOG.md +138 -34
- data/Gemfile +15 -16
- data/README.md +20 -21
- data/Rakefile +16 -11
- data/addressable.gemspec +28 -0
- data/lib/addressable/idna/native.rb +12 -5
- data/lib/addressable/idna/pure.rb +4257 -214
- data/lib/addressable/idna.rb +2 -1
- data/lib/addressable/template.rb +76 -98
- data/lib/addressable/uri.rb +338 -228
- data/lib/addressable/version.rb +4 -3
- data/lib/addressable.rb +2 -0
- data/spec/addressable/idna_spec.rb +29 -13
- data/spec/addressable/net_http_compat_spec.rb +2 -1
- data/spec/addressable/security_spec.rb +2 -1
- data/spec/addressable/template_spec.rb +144 -267
- data/spec/addressable/uri_spec.rb +598 -216
- data/spec/spec_helper.rb +12 -0
- data/tasks/clobber.rake +2 -0
- data/tasks/gem.rake +18 -9
- data/tasks/git.rake +2 -0
- data/tasks/metrics.rake +2 -0
- data/tasks/profile.rake +72 -0
- data/tasks/rspec.rake +3 -1
- data/tasks/yard.rake +2 -0
- metadata +25 -22
- data/data/unicode.data +0 -0
- data/spec/addressable/rack_mount_compat_spec.rb +0 -104
data/lib/addressable/version.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
#--
|
|
3
4
|
# Copyright (C) Bob Aman
|
|
4
5
|
#
|
|
@@ -21,8 +22,8 @@ if !defined?(Addressable::VERSION)
|
|
|
21
22
|
module Addressable
|
|
22
23
|
module VERSION
|
|
23
24
|
MAJOR = 2
|
|
24
|
-
MINOR =
|
|
25
|
-
TINY =
|
|
25
|
+
MINOR = 8
|
|
26
|
+
TINY = 8
|
|
26
27
|
|
|
27
28
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
|
28
29
|
end
|
data/lib/addressable.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
# Copyright (C) Bob Aman
|
|
3
4
|
#
|
|
4
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -26,9 +27,9 @@ shared_examples_for "converting from unicode to ASCII" do
|
|
|
26
27
|
expect(Addressable::IDNA.to_ascii("www.google.com")).to eq("www.google.com")
|
|
27
28
|
end
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
it "should convert '#{
|
|
31
|
-
expect(Addressable::IDNA.to_ascii(
|
|
30
|
+
long = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com'
|
|
31
|
+
it "should convert '#{long}' correctly" do
|
|
32
|
+
expect(Addressable::IDNA.to_ascii(long)).to eq(long)
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
it "should convert 'www.詹姆斯.com' correctly" do
|
|
@@ -37,6 +38,12 @@ shared_examples_for "converting from unicode to ASCII" do
|
|
|
37
38
|
)).to eq("www.xn--8ws00zhy3a.com")
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
it "also accepts unicode strings encoded as ascii-8bit" do
|
|
42
|
+
expect(Addressable::IDNA.to_ascii(
|
|
43
|
+
"www.詹姆斯.com".b
|
|
44
|
+
)).to eq("www.xn--8ws00zhy3a.com")
|
|
45
|
+
end
|
|
46
|
+
|
|
40
47
|
it "should convert 'www.Iñtërnâtiônàlizætiøn.com' correctly" do
|
|
41
48
|
"www.Iñtërnâtiônàlizætiøn.com"
|
|
42
49
|
expect(Addressable::IDNA.to_ascii(
|
|
@@ -134,6 +141,12 @@ shared_examples_for "converting from unicode to ASCII" do
|
|
|
134
141
|
)).to eq("xn--4ud")
|
|
135
142
|
end
|
|
136
143
|
|
|
144
|
+
it "should convert '🌹🌹🌹.ws' correctly" do
|
|
145
|
+
expect(Addressable::IDNA.to_ascii(
|
|
146
|
+
"\360\237\214\271\360\237\214\271\360\237\214\271.ws"
|
|
147
|
+
)).to eq("xn--2h8haa.ws")
|
|
148
|
+
end
|
|
149
|
+
|
|
137
150
|
it "should handle two adjacent '.'s correctly" do
|
|
138
151
|
expect(Addressable::IDNA.to_ascii(
|
|
139
152
|
"example..host"
|
|
@@ -142,9 +155,9 @@ shared_examples_for "converting from unicode to ASCII" do
|
|
|
142
155
|
end
|
|
143
156
|
|
|
144
157
|
shared_examples_for "converting from ASCII to unicode" do
|
|
145
|
-
|
|
146
|
-
it "should convert '#{
|
|
147
|
-
expect(Addressable::IDNA.to_unicode(
|
|
158
|
+
long = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com'
|
|
159
|
+
it "should convert '#{long}' correctly" do
|
|
160
|
+
expect(Addressable::IDNA.to_unicode(long)).to eq(long)
|
|
148
161
|
end
|
|
149
162
|
|
|
150
163
|
it "should return the identity conversion when punycode decode fails" do
|
|
@@ -231,16 +244,17 @@ shared_examples_for "converting from ASCII to unicode" do
|
|
|
231
244
|
)).to eq("\341\206\265")
|
|
232
245
|
end
|
|
233
246
|
|
|
247
|
+
it "should convert '🌹🌹🌹.ws' correctly" do
|
|
248
|
+
expect(Addressable::IDNA.to_unicode(
|
|
249
|
+
"xn--2h8haa.ws"
|
|
250
|
+
)).to eq("\360\237\214\271\360\237\214\271\360\237\214\271.ws")
|
|
251
|
+
end
|
|
252
|
+
|
|
234
253
|
it "should handle two adjacent '.'s correctly" do
|
|
235
254
|
expect(Addressable::IDNA.to_unicode(
|
|
236
255
|
"example..host"
|
|
237
256
|
)).to eq("example..host")
|
|
238
257
|
end
|
|
239
|
-
|
|
240
|
-
it "should normalize 'string' correctly" do
|
|
241
|
-
expect(Addressable::IDNA.unicode_normalize_kc(:'string')).to eq("string")
|
|
242
|
-
expect(Addressable::IDNA.unicode_normalize_kc("string")).to eq("string")
|
|
243
|
-
end
|
|
244
258
|
end
|
|
245
259
|
|
|
246
260
|
describe Addressable::IDNA, "when using the pure-Ruby implementation" do
|
|
@@ -280,7 +294,9 @@ begin
|
|
|
280
294
|
it_should_behave_like "converting from unicode to ASCII"
|
|
281
295
|
it_should_behave_like "converting from ASCII to unicode"
|
|
282
296
|
end
|
|
283
|
-
rescue LoadError
|
|
297
|
+
rescue LoadError => error
|
|
298
|
+
raise error if ENV["CI"] && TestHelper.native_supported?
|
|
299
|
+
|
|
284
300
|
# Cannot test the native implementation without libidn support.
|
|
285
301
|
warn('Could not load native IDN implementation.')
|
|
286
302
|
end
|