From 01d29f0b59cdadfb23c826d9649ed635745fa45e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 18 Nov 2023 08:20:13 -0500 Subject: [PATCH] fix: replace u with U in decodeString, and strip U in toBase64Url --- src/multibase.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multibase.ts b/src/multibase.ts index f4b01cd..58c5750 100644 --- a/src/multibase.ts +++ b/src/multibase.ts @@ -19,7 +19,7 @@ export default abstract class Multibase { } bytes = base32.decode(str); } else if (data[0] === "u") { - bytes = base64urlpad.decode(data); + bytes = base64urlpad.decode(data[0].toUpperCase() + data.substring(1)); } else if (data[0] === ":") { bytes = utf8ToBytes(data); } else { @@ -38,7 +38,7 @@ export default abstract class Multibase { } toBase64Url(): string { - return `u${base64urlpad.encode(this.toBytes())}`; + return `u${base64urlpad.encode(this.toBytes()).substring(1)}`; } toBase58(): string {