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