From 155e0b4c0c9e04a97ca88e9b1cbec72ade0225bf Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 19 Sep 2023 19:31:11 -0400 Subject: [PATCH] fix: bad base32 encoding, multiformats handles the prefix --- src/multibase.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multibase.ts b/src/multibase.ts index 1d34d6d..fdada0c 100644 --- a/src/multibase.ts +++ b/src/multibase.ts @@ -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 {