uri-ni 0.2.3 → 0.2.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/uri/ni/version.rb +1 -1
  3. data/lib/uri/ni.rb +18 -3
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72fad83584f69d2982732c3a0578e6a19a740b4aab3892b5d80e0a73f97b3e9e
4
- data.tar.gz: 94e56f2e88436acb04627be6d8b5b87f3a357dd0c1828ef3569ccdda21541812
3
+ metadata.gz: 6f21e8e7bf5c19fc3eedf94e5a41c401c8bf0c49153b70abf1ec27d301811c9c
4
+ data.tar.gz: 10db96336f2f2509b4079d295af3bac755ecfdc07d06c2fc43fbebb21ba95974
5
5
  SHA512:
6
- metadata.gz: 1d00ea6cb3b0b5dadac6097871743c4f4e709f884093dafd488c8e2a3d0bc2beae7e48c6bf54db509380137a671f0705abf464e18f41a43bbc7cd9500fe7f640
7
- data.tar.gz: bd0774e708e1ec4f5b570a1770bb12363520282e802705ce4b76b2235d186e089c42773374388f56f71c5d6c1ae8958fe95e63a2435410d7191c37dd401b2a24
6
+ metadata.gz: 803def5e52f0265a7cbb881bb874e3d306f352b79f24eee939981591692dad450bb3be5d5f88de050939a8c37154531935401e6f8abf62a7886583b2ed8527ac
7
+ data.tar.gz: d9081a72a683c62a550c28bb19c0c713913a20addebfbb9e203bceb5a04262f982d841bd5d65b0e773722ab10c15ec99da12f88ce9b67734f0a25a27ab00b4fb
@@ -3,7 +3,7 @@ require 'uri/generic'
3
3
 
4
4
  module URI
5
5
  class NI < Generic
6
- VERSION = "0.2.3"
6
+ VERSION = "0.2.4"
7
7
  end
8
8
 
9
9
  # might as well put this here
data/lib/uri/ni.rb CHANGED
@@ -198,14 +198,29 @@ class URI::NI < URI::Generic
198
198
  # @return [URI::NI] the transformed identifier
199
199
  #
200
200
  def self.ingest algorithm = nil, digest
201
- return compute(digest) if digest.is_a? Digest::Instance
202
- return digest if digest.is_a? URI::NI # noop
201
+ if digest.is_a? Digest::Instance
202
+ # this will complain
203
+ algo_for digest, algorithm
204
+ return compute(digest)
205
+ elsif digest.is_a? URI::NI
206
+ raise ArgumentError,
207
+ "digest algorithm #{digest.algorithm} does not match #{algorithm}" if
208
+ algorithm && algorithm != digest.algorithm
209
+ return digest
210
+ end
203
211
 
204
212
  # make sure we're indeed dealing with a string
205
213
  digest = digest.to_s
206
214
 
207
215
  # just parse if it's already a ni: URI string
208
- return URI(digest) if /^ni:/i.match? digest
216
+ if /^ni:/i.match? digest
217
+ digest = URI(digest)
218
+ raise ArgumentError,
219
+ "digest algorithm #{digest.algorithm} does not match #{algorithm}" if
220
+ algorithm && algorithm != digest.algorithm
221
+
222
+ return digest
223
+ end
209
224
 
210
225
  # get the expected length of the digest for the algorithm
211
226
  len = LENGTHS[algorithm.to_s.downcase.to_sym] or raise ArgumentError,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-ni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Taylor