refactor: if we have a Uint8Array and matching hash type, strip it

This commit is contained in:
Derrick Hammer 2023-09-03 20:39:56 -04:00
parent f85a2443d3
commit 8451974d6e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

@ -75,8 +75,8 @@ export function encodeRegistryCid(
raw: boolean = false,
): ErrTuple<string | Uint8Array> {
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);
}
}