diff --git a/ui/src/api/client.ts b/ui/src/api/client.ts index 4e7fd76..5b928da 100644 --- a/ui/src/api/client.ts +++ b/ui/src/api/client.ts @@ -75,6 +75,12 @@ export interface EventQuery { const API_BASE = '/api/v1'; +/** Decode base64 content as UTF-8 (atob only handles Latin-1). */ +function decodeBase64Utf8(b64: string): string { + const bytes = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0)); + return new TextDecoder().decode(bytes); +} + export async function fetchEvents(q: EventQuery): Promise { const params = new URLSearchParams(); if (q.from) params.set('from', q.from.toISOString()); @@ -109,7 +115,7 @@ export async function fetchReadme(source: Source, host: string, repo: string): P if (!resp.ok) return null; const data = await resp.json(); if (data.encoding === 'base64' && data.content) { - return atob(data.content); + return decodeBase64Utf8(data.content); } return data.content ?? null; } @@ -119,7 +125,7 @@ export async function fetchReadme(source: Source, host: string, repo: string): P if (!resp.ok) continue; const data = await resp.json(); if (data.encoding === 'base64' && data.content) { - return atob(data.content); + return decodeBase64Utf8(data.content); } if (data.content) return data.content; }