From 8451974d6e1b42860ccd9560aa01856c98f6cf82 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 3 Sep 2023 20:39:56 -0400 Subject: [PATCH] refactor: if we have a Uint8Array and matching hash type, strip it --- src/cid.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cid.ts b/src/cid.ts index 05a430f..3b8c043 100644 --- a/src/cid.ts +++ b/src/cid.ts @@ -75,8 +75,8 @@ export function encodeRegistryCid( raw: boolean = false, ): ErrTuple { if (hash instanceof Uint8Array) { - if (!Object.values(CID_HASH_TYPES).includes(hash[0])) { - return ["", "invalid hash type"]; + if (Object.values(CID_HASH_TYPES).includes(hash[0])) { + hash = hash.slice(1); } }