refactor: update valid method to be verify, and handle string input
This commit is contained in:
parent
4d721ef4ab
commit
0ad6d611a6
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue