identical-links-same-purpose-evaluate.js 763 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { dom, text } from '../../commons';
  2. /**
  3. * Note: `identical-links-same-purpose-after` fn, helps reconcile the results
  4. */
  5. function identicalLinksSamePurposeEvaluate(node, options, virtualNode) {
  6. const accText = text.accessibleTextVirtual(virtualNode);
  7. const name = text
  8. .sanitize(
  9. text.removeUnicode(accText, {
  10. emoji: true,
  11. nonBmp: true,
  12. punctuations: true
  13. })
  14. )
  15. .toLowerCase();
  16. if (!name) {
  17. return undefined;
  18. }
  19. /**
  20. * Set `data` and `relatedNodes` for use in `after` fn
  21. */
  22. const afterData = {
  23. name,
  24. urlProps: dom.urlPropsFromAttribute(node, 'href')
  25. };
  26. this.data(afterData);
  27. this.relatedNodes([node]);
  28. return true;
  29. }
  30. export default identicalLinksSamePurposeEvaluate;