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.
@@ -1,4 +1,5 @@
1
- # encoding:utf-8
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 = 5
25
- TINY = 0
25
+ MINOR = 8
26
+ TINY = 8
26
27
 
27
28
  STRING = [MAJOR, MINOR, TINY].join('.')
28
29
  end
data/lib/addressable.rb CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'addressable/uri'
2
4
  require 'addressable/template'
@@ -1,4 +1,5 @@
1
- # coding: utf-8
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
- LONG = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com'
30
- it "should convert '#{LONG}' correctly" do
31
- expect(Addressable::IDNA.to_ascii(LONG)).to eq(LONG)
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
- LONG = 'AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallum.com'
146
- it "should convert '#{LONG}' correctly" do
147
- expect(Addressable::IDNA.to_unicode(LONG)).to eq(LONG)
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
@@ -1,4 +1,5 @@
1
- # coding: utf-8
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");
@@ -1,4 +1,5 @@
1
- # coding: utf-8
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");