Skip to content

Commit 8f0fcda

Browse files
committed
fix: wrong avatar URL when set to empty string
1 parent 7cddd31 commit 8f0fcda

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/bot/levilamina-fetcher.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ export class LeviLaminaFetcher extends GitHubFetcher {
5151
return null
5252
}
5353

54-
let avatarUrl = tooth.info?.avatar_url ?? `https://avatars.githubusercontent.com/${repo.owner}`
54+
let avatarUrl = tooth.info?.avatar_url ?? ''
55+
56+
// If empty, use the repository owner's avatar
57+
if (avatarUrl === '') {
58+
avatarUrl = `https://avatars.githubusercontent.com/${repo.owner}`
59+
}
5560

5661
// Check if avatarUrl is relative and make it absolute if needed
5762
if (!/^(?:[a-z+]+:)?\//i.test(avatarUrl)) {
5863
avatarUrl = `https://raw.githubusercontent.com/${repo.owner}/${repo.repo}/HEAD/${avatarUrl}`
5964
}
65+
6066
// Check if avatarUrl starts with https://github.com/{owner}/{repo}/blob and convert it to raw.githubusercontent.com
6167
const githubUrlRegex = /^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([\w.-]+)\/blob\/(.+)/
6268
const githubUrlRegexMatch = githubUrlRegex.exec(avatarUrl)

0 commit comments

Comments
 (0)