2019-08-31 20:51:14 -07:00

17 lines
530 B
TypeScript

import buildUrl from 'wherehows-web/utils/build-url';
import { IMailHeaderRecord } from 'wherehows-web/typings/app/helpers/email';
/**
* Constructs a `mailto:` address with supplied email headers as query parameters
* @param {IMailHeaderRecord} [headers={}]
* @returns {string}
*/
const buildMailToUrl = (headers: IMailHeaderRecord = {}): string => {
const { to = '', ...otherHeaders } = headers;
const mailTo = `mailto:${encodeURIComponent(to)}`;
return buildUrl(mailTo, otherHeaders);
};
export { buildMailToUrl };