Fix code preview link to use HEAD instead of 'main' (since the main branch might not be named main)

This commit is contained in:
bkellam 2024-09-06 19:12:52 -07:00
parent 69edcbd3ab
commit 19b36e5813

View file

@ -63,11 +63,11 @@ export const getCodeHostFilePreviewLink = (repoName: string, filePath: string):
const info = getRepoCodeHostInfo(repoName);
if (info?.type === "github") {
return `${info.repoLink}/tree/main/${filePath}`;
return `${info.repoLink}/blob/HEAD/${filePath}`;
}
if (info?.type === "gitlab") {
return `${info.repoLink}/-/blob/main/${filePath}`;
return `${info.repoLink}/-/blob/HEAD/${filePath}`;
}
return undefined;