Skip to content

Commit 8c2abf8

Browse files
committed
fix: equality check
1 parent c9e970f commit 8c2abf8

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/cid.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,19 @@ export class CID {
7878
/** @readonly */
7979
this.bytes = bytes
8080

81-
// ArrayBufferView
82-
/** @readonly */
83-
this.byteOffset = bytes.byteOffset
84-
/** @readonly */
85-
this.byteLength = bytes.byteLength
86-
8781
// Circular reference
8882
/** @readonly */
8983
this.asCID = this
9084
}
9185

86+
get byteOffset () {
87+
return this.bytes.byteOffset
88+
}
89+
90+
get byteLength () {
91+
return this.bytes.byteLength
92+
}
93+
9294
/**
9395
* @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>}
9496
*/
@@ -274,6 +276,10 @@ export class CID {
274276
throw new Error('String codecs are no longer supported')
275277
}
276278

279+
if (!(digest.bytes instanceof Uint8Array)) {
280+
throw new Error('Invalid multihash digest was passed')
281+
}
282+
277283
switch (version) {
278284
case 0: {
279285
if (code !== DAG_PB_CODE) {

0 commit comments

Comments
 (0)