From 0f4b9789401075ac783edd9bd91e4e3f417e4329 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 18 Nov 2023 08:14:47 -0500 Subject: [PATCH] fix: more base64urlpad fixes --- src/multibase.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/multibase.ts b/src/multibase.ts index 7b26e93..f4b01cd 100644 --- a/src/multibase.ts +++ b/src/multibase.ts @@ -19,11 +19,7 @@ export default abstract class Multibase { } bytes = base32.decode(str); } else if (data[0] === "u") { - let str = data[0].toUpperCase() + data.substring(1); - while (str.length % 4 !== 0) { - str += "="; - } - bytes = base64urlpad.decode(str); + bytes = base64urlpad.decode(data); } else if (data[0] === ":") { bytes = utf8ToBytes(data); } else { @@ -42,7 +38,7 @@ export default abstract class Multibase { } toBase64Url(): string { - return `u${base64.encode(this.toBytes())}`; + return `u${base64urlpad.encode(this.toBytes())}`; } toBase58(): string {