From e6ba25358575efedefa94442a08f9c33c104df19 Mon Sep 17 00:00:00 2001 From: Flora Thiebaut Date: Tue, 23 Jul 2024 10:49:08 +0200 Subject: [PATCH] fix: use safe URL for repository icon (#3247) Fixes #3246. --- .../CodeRepositories/CodeRepositoryDisplay.tsx | 10 +++++++--- client/src/utils/helpers/safeNewUrl.utils.ts | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx b/client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx index fc9b6b5e2..146424d68 100644 --- a/client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx +++ b/client/src/features/ProjectPageV2/ProjectPageContent/CodeRepositories/CodeRepositoryDisplay.tsx @@ -435,12 +435,16 @@ interface RepositoryIconProps { } function RepositoryIcon({ className, provider }: RepositoryIconProps) { - if (provider == null) { + const iconUrl = useMemo( + // eslint-disable-next-line spellcheck/spell-checker + () => (provider != null ? safeNewUrl("/favicon.ico", provider) : null), + [provider] + ); + + if (iconUrl == null) { return null; } - // eslint-disable-next-line spellcheck/spell-checker - const iconUrl = new URL("/favicon.ico", provider); return (