mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-17 06:45:25 +00:00
fix(gitlab): Properly handle auth for Gitlab project avatars (#345)
This commit is contained in:
parent
1ea377e7d6
commit
e423b56f42
2 changed files with 5 additions and 3 deletions
|
|
@ -121,7 +121,10 @@ export const compileGitlabConfig = async (
|
||||||
const isFork = project.forked_from_project !== undefined;
|
const isFork = project.forked_from_project !== undefined;
|
||||||
const repoDisplayName = project.path_with_namespace;
|
const repoDisplayName = project.path_with_namespace;
|
||||||
const repoName = path.join(repoNameRoot, repoDisplayName);
|
const repoName = path.join(repoNameRoot, repoDisplayName);
|
||||||
|
// project.avatar_url is not directly accessible with tokens; use the avatar API endpoint if available
|
||||||
|
const avatarUrl = project.avatar_url
|
||||||
|
? new URL(`/api/v4/projects/${project.id}/avatar`, hostUrl).toString()
|
||||||
|
: null;
|
||||||
logger.debug(`Found gitlab repo ${repoDisplayName} with webUrl: ${projectUrl}`);
|
logger.debug(`Found gitlab repo ${repoDisplayName} with webUrl: ${projectUrl}`);
|
||||||
|
|
||||||
const record: RepoData = {
|
const record: RepoData = {
|
||||||
|
|
@ -132,7 +135,7 @@ export const compileGitlabConfig = async (
|
||||||
webUrl: projectUrl,
|
webUrl: projectUrl,
|
||||||
name: repoName,
|
name: repoName,
|
||||||
displayName: repoDisplayName,
|
displayName: repoDisplayName,
|
||||||
imageUrl: project.avatar_url,
|
imageUrl: avatarUrl,
|
||||||
isFork: isFork,
|
isFork: isFork,
|
||||||
isArchived: !!project.archived,
|
isArchived: !!project.archived,
|
||||||
org: {
|
org: {
|
||||||
|
|
|
||||||
|
|
@ -419,7 +419,6 @@ export const getRepoImageSrc = (imageUrl: string | undefined, repoId: number, do
|
||||||
// List of known public instances that don't require authentication
|
// List of known public instances that don't require authentication
|
||||||
const publicHostnames = [
|
const publicHostnames = [
|
||||||
'github.com',
|
'github.com',
|
||||||
'gitlab.com',
|
|
||||||
'avatars.githubusercontent.com',
|
'avatars.githubusercontent.com',
|
||||||
'gitea.com',
|
'gitea.com',
|
||||||
'bitbucket.org',
|
'bitbucket.org',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue