refactor: update valid method to be verify, and handle string input

This commit is contained in:
Derrick Hammer 2023-09-08 12:30:50 -04:00
parent 4d721ef4ab
commit 0ad6d611a6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ export default class CID extends Multibase {
return new CID(type, new Multihash(bytes), size);
}
static valid(bytes: Uint8Array): boolean {
static verify(bytes: string | Uint8Array): boolean {
if (typeof bytes === "string") {
bytes = Multibase.decodeString(bytes);
}
try {
CID._init(bytes);
} catch {