uri-idna 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6682f4500b6119fcd467ff88793d5a2d4522308ea4884cc6f69f04cb073d1089
4
- data.tar.gz: 1e63bd541e8020f789916a82950a81d2f67b8d29a882f45d7c4a369a10c15de1
3
+ metadata.gz: a31f65444a2088912d65c6755cf7e1cb16ae1936c801245b29804f55414a6b67
4
+ data.tar.gz: 1538c13b89e089e53f7d249ac6b3ce628e163bbd65d30f36cddc2b97007382b3
5
5
  SHA512:
6
- metadata.gz: 86032ea0573558c6386154a29265dddc81e8914a9720643bceab6f80de49d9f11ff2fc8bf5bfa789c84a515050457e9493937040541831a8d14394f49e15549d
7
- data.tar.gz: 493f974a03ccf2abc69e1090f2a61d029a5f2e47a3725f87bdc3bf6ced69a7d9e052a424ddc95268c0b26a4354c7b31d72268c9a404d4b16180e77db8c5ff009
6
+ metadata.gz: d26a6d183474bc619cf282d712874c06a91a522207c539ee9a1c67bf51474b3084e67dea2a1f2315b1852204eeea5b3df67bc20412a26d5bd18561dc3899833e
7
+ data.tar.gz: 3b2d6a1ed2a1e79e55e9569959a5fcc86203e22696c03bbce33b788681385072026c4dcab2888346249856ffd0ea9a66a13071caa5309ba8c8cb7040af9a7d2e
data/CHANGELOG.md CHANGED
@@ -5,23 +5,33 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog],
6
6
  and this project adheres to [Semantic Versioning].
7
7
 
8
- ## [Unreleased]
8
+ ## [0.2.2] - 2023-11-25
9
+
10
+ ### Changed
11
+
12
+ - Internal implementation moved to regex-based algorithm to improve performance. ([@skryukov])
13
+
14
+ ## [0.2.1] - 2023-11-15
15
+
16
+ ### Changed
17
+
18
+ - Various performance and memory optimizations. ([@skryukov])
9
19
 
10
20
  ## [0.2.0] - 2023-11-14
11
21
 
12
22
  ### Added
13
23
 
14
- - WHATWG IDNA functions
24
+ - WHATWG IDNA functions. ([@skryukov])
15
25
 
16
26
  ### Changed
17
27
 
18
- - **BREAKING!** Names of options updated to match UTS46 flags
19
- - Unicode version updated to 15.1
20
- - UTS46 functions now support Revision 31
28
+ - **BREAKING!** Names of options updated to match UTS46 flags. ([@skryukov])
29
+ - Unicode version updated to 15.1. ([@skryukov])
30
+ - UTS46 functions now support Revision 31. ([@skryukov])
21
31
 
22
32
  ### Fixed
23
33
 
24
- - IDNA2008 functions now support not only labels, but full domains
34
+ - IDNA2008 functions now support not only labels, but full domains. ([@skryukov])
25
35
 
26
36
  ## [0.1.0] - 2023-08-05
27
37
 
@@ -31,7 +41,9 @@ and this project adheres to [Semantic Versioning].
31
41
 
32
42
  [@skryukov]: https://github.com/skryukov
33
43
 
34
- [Unreleased]: https://github.com/skryukov/uri-idna/compare/v0.2.0...HEAD
44
+ [Unreleased]: https://github.com/skryukov/uri-idna/compare/v0.2.2...HEAD
45
+ [0.2.2]: https://github.com/skryukov/uri-idna/compare/v0.2.1...v0.2.2
46
+ [0.2.1]: https://github.com/skryukov/uri-idna/compare/v0.2.0...v0.2.1
35
47
  [0.2.0]: https://github.com/skryukov/uri-idna/compare/v0.1.0...v0.2.0
36
48
  [0.1.0]: https://github.com/skryukov/uri-idna/commits/v0.1.0
37
49
 
data/README.md CHANGED
@@ -256,7 +256,7 @@ To specify Unicode version, use `VERSION` environment variable, e.g. `VERSION=15
256
256
 
257
257
  By default, used Unicode version is the one used by the Ruby version (`RbConfig::CONFIG["UNICODE_VERSION"]`).
258
258
 
259
- To set directory for generated files, use `DATA_DIR` environment variable, e.g. `DATA_DIR=lib/uri/idna/data bundle exec rake idna:generate`.
259
+ To set directory for generated files, use `DEST_DIR` environment variable, e.g. `DEST_DIR=lib/uri/idna/data bundle exec rake idna:generate`.
260
260
 
261
261
  Unicode data cached in the `tmp` directory by default, to change it, use `CACHE_DIR` environment variable, e.g. `CACHE_DIR=~/.cache/unicode_data bundle exec rake idna:generate`.
262
262
 
@@ -1,27 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "validation/label"
4
- require_relative "validation/codepoint"
5
4
  require_relative "validation/bidi"
6
5
 
7
6
  module URI
8
7
  module IDNA
9
8
  class BaseProcessing
9
+ class << self
10
+ def default_options
11
+ @default_options ||= options_class.new
12
+ end
13
+
14
+ def options_class
15
+ raise NotImplementedError, "Implement #options_class method"
16
+ end
17
+ end
18
+
10
19
  def initialize(domain_name, **options)
11
20
  @domain_name = domain_name
12
- @options = options_class.new(**options)
21
+ @options = options.any? ? self.class.options_class.new(**options) : self.class.default_options
13
22
  end
14
23
 
15
24
  private
16
25
 
17
26
  attr_reader :domain_name, :options
18
27
 
19
- def options_class
20
- raise NotImplementedError, "Implement #options_class method"
21
- end
22
-
23
28
  def punycode_decode(label)
24
29
  raise Error, "Label contains non-ASCII code point" unless label.ascii_only?
30
+ raise Error, "A-label must not end with a hyphen" if label[-1] == "-"
25
31
 
26
32
  code = label[ACE_PREFIX.length..]
27
33
  raise Error, "Malformed A-label, no Punycode eligible content found" if code.empty?
@@ -60,6 +66,12 @@ module URI
60
66
 
61
67
  [labels, trailing_dot]
62
68
  end
69
+
70
+ def check_bidi?
71
+ return @check_bidi if instance_variable_defined?(:@check_bidi)
72
+
73
+ @check_bidi = options.check_bidi? && Validation::Bidi.check?(domain_name)
74
+ end
63
75
  end
64
76
  end
65
77
  end