Skip to content

Commit

Permalink
revert encoding changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ycmjason committed Oct 16, 2024
1 parent 6ff26f3 commit aaf0570
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/utils/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ export const encodeBase64Url = (
);
})();

return convertBase64ToBase64url(btoa(bytes));
return btoa(bytes)
.replace(/\+/g, "-")
.replace(/\//g, "_")
.replace(/=+$/, "");
};

function convertBase64ToBase64url(b64: string) {
return b64.endsWith("=")
? b64.endsWith("==")
? b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -2)
: b64.replace(/\+/g, "-").replace(/\//g, "_").slice(0, -1)
: b64.replace(/\+/g, "-").replace(/\//g, "_");
}

0 comments on commit aaf0570

Please sign in to comment.