mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-24 18:10:11 +00:00
17 lines
530 B
TypeScript
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 };
|