Skip to content

Commit 18c0c05

Browse files
committed
fix: fix links
1 parent 335af69 commit 18c0c05

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

zendesk_app/src/app/components/AutosendModal/AutosendModal.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,28 @@ export const AutosendModal = ({
5656
}
5757

5858
const getEndUserContentHtml = (conversationEntry: ZendeskConversationEntry) => {
59-
return `${conversationEntry.message.content || ''}
60-
${conversationEntry.attachments
59+
const messageContent = (conversationEntry.message.content || '').replace(
60+
/<a\b(?![^>]*\btarget=)[^>]*>/gi,
61+
(match: string) => {
62+
// Add target and rel attributes to open links in a new tab
63+
return match.replace(/<a/, '<a target="_blank" rel="noopener noreferrer"');
64+
}
65+
);
66+
67+
const attachmentLinks = conversationEntry.attachments
6168
?.map(
6269
(att: any) => `
63-
<div style="margin-top: 1em;">
64-
<a href="${att.contentUrl}" target="_blank" rel="noopener noreferrer">
65-
📎 ${att.filename}
66-
</a>
67-
</div>
68-
`
70+
<div style="margin-top: 1em;">
71+
<a href="${att.contentUrl}" target="_blank" rel="noopener noreferrer">
72+
📎 ${att.filename}
73+
</a>
74+
</div>
75+
`
6976
)
70-
.join('')}`
71-
}
77+
.join('') || '';
78+
79+
return `${messageContent}${attachmentLinks}`;
80+
};
7281

7382
return (
7483
<div className={styles.main_container}>

0 commit comments

Comments
 (0)