Skip to content

Commit

Permalink
[Hotfix] Less false positive in link detection logic (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
apganapa-adobe authored Nov 9, 2024
2 parents bf6124c + 53fa040 commit 91f69a6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions events/blocks/profile-cards/profile-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,20 @@ async function decorateSocialIcons(cardContainer, socialLinks) {

const svgEls = await getSVGsfromFile(svgPath, SUPPORTED_SOCIAL);
if (!svgEls || svgEls.length === 0) return;

socialLinks.forEach((social) => {
const { link } = social;
const platform = SUPPORTED_SOCIAL.find((p) => link.toLowerCase().includes(p)) || 'web';

if (!link) return;

let platform = '';
try {
const url = new URL(link);
const hostname = url.hostname.toLowerCase();
platform = SUPPORTED_SOCIAL.find((p) => hostname.includes(`${p}.`)) || 'web';
} catch (error) {
platform = 'web';
}

const svgEl = svgEls.find((el) => el.name === platform);
if (!svgEl) return;

Expand Down

0 comments on commit 91f69a6

Please sign in to comment.