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.
- checksums.yaml +4 -4
- data/lib/uri/ni/version.rb +1 -1
- data/lib/uri/ni.rb +18 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f21e8e7bf5c19fc3eedf94e5a41c401c8bf0c49153b70abf1ec27d301811c9c
|
|
4
|
+
data.tar.gz: 10db96336f2f2509b4079d295af3bac755ecfdc07d06c2fc43fbebb21ba95974
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 803def5e52f0265a7cbb881bb874e3d306f352b79f24eee939981591692dad450bb3be5d5f88de050939a8c37154531935401e6f8abf62a7886583b2ed8527ac
|
|
7
|
+
data.tar.gz: d9081a72a683c62a550c28bb19c0c713913a20addebfbb9e203bceb5a04262f982d841bd5d65b0e773722ab10c15ec99da12f88ce9b67734f0a25a27ab00b4fb
|
data/lib/uri/ni/version.rb
CHANGED
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
|
-
|
|
202
|
-
|
|
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
|
-
|
|
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,
|