chore: replace uint8-to-base64 with native btoa/atob (#38579)

Replace the single-use `uint8-to-base64` dependency with native
`btoa`/`atob`. The implementation is exactly identical.

---------

Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
silverwind
2026-07-22 21:37:11 +02:00
committed by GitHub
parent ae2ff1b467
commit 1d698f12ce
4 changed files with 8 additions and 14 deletions
+2 -5
View File
@@ -1,4 +1,3 @@
import {decode, encode} from 'uint8-to-base64';
import type {IssuePageInfo, IssuePathInfo, RepoOwnerPathInfo} from './types.ts';
import {toggleElemClass, toggleElem} from './utils/dom.ts';
@@ -158,7 +157,7 @@ export function toAbsoluteUrl(url: string): string {
/** Encode an Uint8Array into a URLEncoded base64 string. */
export function encodeURLEncodedBase64(uint8Array: Uint8Array): string {
return encode(uint8Array)
return btoa(Array.from(uint8Array, (byte) => String.fromCharCode(byte)).join(''))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
@@ -166,9 +165,7 @@ export function encodeURLEncodedBase64(uint8Array: Uint8Array): string {
/** Decode a URLEncoded base64 to an Uint8Array. */
export function decodeURLEncodedBase64(base64url: string): Uint8Array {
return decode(base64url
.replace(/_/g, '/')
.replace(/-/g, '+'));
return Uint8Array.from(atob(base64url.replace(/_/g, '/').replace(/-/g, '+')), (ch) => ch.charCodeAt(0));
}
const domParser = new DOMParser();