17 lines
530 B
TypeScript
Raw Normal View History

import buildUrl from 'wherehows-web/utils/build-url';
2018-09-26 21:57:16 -07:00
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;
2018-09-26 21:57:16 -07:00
const mailTo = `mailto:${encodeURIComponent(to)}`;
2018-09-26 21:57:16 -07:00
return buildUrl(mailTo, otherHeaders);
};
export { buildMailToUrl };