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();
}
if (source === 'gitea') {
// Gitea returns JSON with base64-encoded content
const resp = await fetch(`https://${host}/api/v1/repos/${repo}/contents/README.md`);
if (!resp.ok) return null;
// Gitea returns JSON with base64-encoded content. Try common casings.
for (const name of ['README.md', 'readme.md', 'Readme.md']) {
const resp = await fetch(`https://${host}/api/v1/repos/${repo}/contents/${name}`);
if (!resp.ok) continue;
const data = await resp.json();
if (data.encoding === 'base64' && data.content) {
return atob(data.content);
}
return data.content ?? null;
if (data.content) return data.content;
}
return null;
}
return null;
}