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:
@@ -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;
|
||||
const data = await resp.json();
|
||||
if (data.encoding === 'base64' && data.content) {
|
||||
return atob(data.content);
|
||||
// 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);
|
||||
}
|
||||
if (data.content) return data.content;
|
||||
}
|
||||
return data.content ?? null;
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user