Skip to content

Commit

Permalink
fix(EmailLink): encode space as %20 instead of +
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenbelien committed Feb 4, 2025
1 parent b68d3a8 commit 0cad1ab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/blocks/ActionBlock/EmailLink.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ const { emailAddress, emailSubject, emailBody, ...props } = Astro.props;
const getHref = ({ emailAddress, emailSubject, emailBody }: EmailLinkProps) => {
const url = new URL(`mailto:${emailAddress}`);
if (emailSubject) url.searchParams.set('subject', emailSubject);
if (emailBody) url.searchParams.set('body', emailBody);
const params = [
...emailSubject ? [`subject=${encodeURIComponent(emailSubject)}`] : [],
...emailBody ? [`body=${encodeURIComponent(emailBody)}`] : [],
];
if (params.length) url.search = params.join('&');
return url.href;
};
Expand Down

0 comments on commit 0cad1ab

Please sign in to comment.