fix: try multiple readme filename casings for Gitea repos

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-05 16:19:34 +03:00
parent 46ef63a68e
commit f676ecdc19

View File

@@ -112,14 +112,17 @@ export async function fetchReadme(source: Source, host: string, repo: string): P
return resp.text(); return resp.text();
} }
if (source === 'gitea') { if (source === 'gitea') {
// Gitea returns JSON with base64-encoded content // Gitea returns JSON with base64-encoded content. Try common casings.
const resp = await fetch(`https://${host}/api/v1/repos/${repo}/contents/README.md`); for (const name of ['README.md', 'readme.md', 'Readme.md']) {
if (!resp.ok) return null; const resp = await fetch(`https://${host}/api/v1/repos/${repo}/contents/${name}`);
if (!resp.ok) continue;
const data = await resp.json(); const data = await resp.json();
if (data.encoding === 'base64' && data.content) { if (data.encoding === 'base64' && data.content) {
return atob(data.content); return atob(data.content);
} }
return data.content ?? null; if (data.content) return data.content;
}
return null;
} }
return null; return null;
} }