Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseHighlightedAttribute({
preTag = HIGHLIGHT_TAGS.highlightPreTag,
postTag = HIGHLIGHT_TAGS.highlightPostTag,
highlightedValue,
}) {
const splitByPreTag = highlightedValue.split(preTag);
const firstValue = splitByPreTag.shift();
const elements =
firstValue === '' ? [] : [{ value: firstValue, isHighlighted: false }];
if (postTag === preTag) {
let isHighlighted = true;
splitByPreTag.forEach(split => {
elements.push({ value: split, isHighlighted });
isHighlighted = !isHighlighted;
});
} else {
splitByPreTag.forEach(split => {