All files / outline viewAsMbox.ts

100% Statements 9/9
50% Branches 2/4
100% Functions 2/2
100% Lines 8/8

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 12 13 14 1510x 1x         1x   1x 1x 1x 1x 1x    
export default (dom) => function viewAsMbox (obj) {
  const anchor = dom.createElement('a')
  // previous implementation assumed email address was Literal. fixed.
 
  // FOAF mboxs must NOT be literals -- must be mailto: URIs.
 
  let address = obj.termType === 'NamedNode' ? obj.uri : obj.value // this way for now
  // if (!address) return viewAsBoringDefault(obj)
  const index = address.indexOf('mailto:')
  address = index >= 0 ? address.slice(index + 7) : address
  anchor.setAttribute('href', 'mailto:' + address)
  anchor.appendChild(dom.createTextNode(address))
  return anchor
}