diff --git a/src/components/GoalsComponents/MyGoal.tsx b/src/components/GoalsComponents/MyGoal.tsx index 3eaf51496..4b09060c6 100644 --- a/src/components/GoalsComponents/MyGoal.tsx +++ b/src/components/GoalsComponents/MyGoal.tsx @@ -207,22 +207,27 @@ const MyGoal: React.FC = ({ goal, showActions, setShowActions }) =>
{replacedString.split(" ").map((ele, index) => { - if (ele.includes("zURL-")) { - const urlIndex = Number(ele.split("-")[1]); - const originalUrl = urlsWithIndexes[urlIndex]; - const summarizedUrl = summarizeUrl(originalUrl); - console.log(originalUrl); - + const replacedUrls = Array.from(ele.matchAll(/zURL-(\d+)/g)); + if (replacedUrls.length) { return ( - { - window.open(originalUrl, "_blank"); - }} - > - {index === 0 ? summarizedUrl : ` ${summarizedUrl}`} - + + {replacedUrls.map(([url, digitStr]) => { + const urlIndex = Number.parseInt(digitStr, 10); + const originalUrl = urlsWithIndexes[urlIndex]; + const summarizedUrl = summarizeUrl(originalUrl); + return ( + { + window.open(originalUrl, "_blank"); + }} + > + {index === 0 ? summarizedUrl : ` ${summarizedUrl}`} + + ); + })} + ); } return {index === 0 ? ele : ` ${ele}`};