Skip to content

Commit 9fc6655

Browse files
authored
Add ensureAbsoluteUrl function for website links
1 parent 76d2faa commit 9fc6655

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

client/pages/home/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ async function GhButton({ url, title, count, icon = 'github' }) {
149149
);
150150
}
151151

152+
function ensureAbsoluteUrl(url) {
153+
if (!url) return '';
154+
if (/^https?:\/\//.test(url)) return url;
155+
return `https://${url}`;
156+
}
157+
152158
function renderSponsorCard(sponsor) {
153159
const { id, name, tier, tagline, website, image } = sponsor;
154160
const initials = name
@@ -166,7 +172,7 @@ function renderSponsorCard(sponsor) {
166172
return (
167173
<Tag
168174
key={id}
169-
{...(website ? { href: website, target: '_blank', rel: 'noopener' } : {})}
175+
{...(website ? { href: ensureAbsoluteUrl(website), target: '_blank', rel: 'noopener' } : {})}
170176
className={`sponsor-card sponsor-card-${tier}`}
171177
title={tierLabel}
172178
>

0 commit comments

Comments
 (0)