From 233ff40a24dd90952e6f0eb34ef714d40579eabf Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Wed, 3 Dec 2025 07:57:55 +0100 Subject: [PATCH] fix(frontend/marketplace): Fix rendering creator links without schema (#11516) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [OPEN-2871: TypeError: URL constructor: www.agpt.co is not a valid URL.](https://linear.app/autogpt/issue/OPEN-2871/typeerror-url-constructor-wwwagptco-is-not-a-valid-url) - [Sentry Issue BUILDER-56D: TypeError: URL constructor: www.agpt.co is not a valid URL.](https://significant-gravitas.sentry.io/issues/7081476631/) ### Changes 🏗️ - Amend URL handling in `CreatorLinks` to correctly handle URLs with implicit schema ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - Trivial change, CI is sufficient --- .../components/CreatorLinks/CreatorLinks.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CreatorLinks/CreatorLinks.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CreatorLinks/CreatorLinks.tsx index 5bbfa9a939..7466c3eb1f 100644 --- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CreatorLinks/CreatorLinks.tsx +++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CreatorLinks/CreatorLinks.tsx @@ -5,6 +5,22 @@ interface CreatorLinksProps { links: string[]; } +function normalizeURL(url: string): string { + if (!url.startsWith("http://") && !url.startsWith("https://")) { + return `https://${url}`; + } + return url; +} + +function getHostnameFromURL(url: string): string { + try { + const normalizedURL = normalizeURL(url); + return new URL(normalizedURL).hostname.replace("www.", ""); + } catch { + return url.replace(/^(https?:\/\/)?(www\.)?/, ""); + } +} + export const CreatorLinks = ({ links }: CreatorLinksProps) => { if (!links || links.length === 0) { return null; @@ -12,13 +28,13 @@ export const CreatorLinks = ({ links }: CreatorLinksProps) => { const renderLinkButton = (url: string) => (
- {new URL(url).hostname.replace("www.", "")} + {getHostnameFromURL(url)}
{getIconForSocial(url, {