fix: bad base32 encoding, multiformats handles the prefix

This commit is contained in:
Derrick Hammer 2023-09-19 19:31:11 -04:00
parent 6cf2481164
commit 155e0b4c0c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

@ -13,7 +13,7 @@ export default abstract class Multibase {
} else if (data[0] === "f") {
bytes = Uint8Array.from(hexToBytes(data.substring(1)));
} else if (data[0] === "b") {
let str = data.substring(1).toUpperCase();
let str = data;
while (str.length % 4 !== 0) {
str += "=";
}
@ -38,7 +38,7 @@ export default abstract class Multibase {
}
toBase32(): string {
return `b${base32.encode(this.toBytes()).replace(/=/g, "").toLowerCase()}`;
return `${base32.encode(this.toBytes()).replace(/=/g, "").toLowerCase()}`;
}
toBase64Url(): string {