From 004523ec96a79f9796b01d8e36955a4d066011d0 Mon Sep 17 00:00:00 2001 From: Sagar Pathak Date: Mon, 17 Feb 2025 12:53:15 -0600 Subject: [PATCH 1/2] Support build avatars sourced from non-GitHub URLs #1441 --- src/actions/recomputeReduxState.js | 3 +++ src/components/info/byline.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index ef9e3c680..67aeceafb 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -755,6 +755,9 @@ const createMetadataStateFromJSON = (json) => { if (json.meta.build_url) { metadata.buildUrl = json.meta.build_url; } + if (json.meta.build_avatar) { + metadata.buildAvatar = json.meta.build_avatar; + } if (json.meta.data_provenance) { metadata.dataProvenance = json.meta.data_provenance; } diff --git a/src/components/info/byline.js b/src/components/info/byline.js index 83f136611..8528c495d 100644 --- a/src/components/info/byline.js +++ b/src/components/info/byline.js @@ -39,9 +39,14 @@ const AvatarImg = styled.img` * which is a GitHub repo. The avatar image is fetched from GitHub (by the client). */ function renderAvatar(t, metadata) { - const repo = metadata.buildUrl; - if (typeof repo === 'string') { - const match = repo.match(/(https?:\/\/)?(www\.)?github.com\/([^/]+)/); + const { buildAvatar, buildUrl } = metadata; + // If buildAvatar is present, return the avatar image + if (buildAvatar) { + return ; + } + + if (typeof buildUrl === 'string') { + const match = buildUrl.match(/(https?:\/\/)?(www\.)?github.com\/([^/]+)/); if (match) { return ( From e271252622f1756b166c5e85084ff657f87d21c1 Mon Sep 17 00:00:00 2001 From: Sagar Pathak Date: Thu, 20 Feb 2025 11:24:13 -0600 Subject: [PATCH 2/2] added string type check for buildAvatar --- src/components/info/byline.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/info/byline.js b/src/components/info/byline.js index 8528c495d..ff6b515e6 100644 --- a/src/components/info/byline.js +++ b/src/components/info/byline.js @@ -40,8 +40,7 @@ const AvatarImg = styled.img` */ function renderAvatar(t, metadata) { const { buildAvatar, buildUrl } = metadata; - // If buildAvatar is present, return the avatar image - if (buildAvatar) { + if (typeof buildAvatar === 'string') { return ; }