All files / elements/typography/Link utils.js

100% Statements 5/5
100% Branches 8/8
100% Functions 3/3
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11  278x           1112x 278x    
export function emailHrefString(props) {
  const otherProps = {
    bcc: props.bcc,
    body: props.body,
    cc: props.cc,
    subject: props.subject,
  };
  const trimmedProps = Object.keys(otherProps).filter(key => !!props[key]).map(key => encodeURI(`${key}=${props[key]}`)).join('&');
  return `${props.to || trimmedProps ? 'mailto:' : ''}${props.to || ''}${trimmedProps ? `?${trimmedProps}` : ''}`;
}