department-of-veterans-affairs/vets-website

View on GitHub
src/applications/search/utils.js

Summary

Maintainability
A
0 mins
Test Coverage
export function formatResponseString(string, stripAll = false) {
  if (stripAll) {
    return string.replace(/[\ue000\ue001]/g, '');
  }

  return string.replace(/\ue000/g, '<strong>').replace(/\ue001/g, '</strong>');
}

export function truncateResponseString(string, maxLength) {
  if (string.length <= maxLength) {
    return string;
  }
  return `${string.slice(0, maxLength)}...`;
}

export function removeDoubleBars(string) {
  return string.replace('| Veterans Affairs', '');
}