diff options
Diffstat (limited to 'webapp/utils/text_formatting.jsx')
-rw-r--r-- | webapp/utils/text_formatting.jsx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/webapp/utils/text_formatting.jsx b/webapp/utils/text_formatting.jsx index 9f983a1ee..171226558 100644 --- a/webapp/utils/text_formatting.jsx +++ b/webapp/utils/text_formatting.jsx @@ -395,7 +395,13 @@ function parseSearchTerms(searchTerm) { } // remove punctuation from each term - terms = terms.map((term) => term.replace(puncStart, '').replace(puncEnd, '')); + terms = terms.map((term) => { + term.replace(puncStart, ''); + if (term.charAt(term.length - 1) !== '*') { + term.replace(puncEnd, ''); + } + return term; + }); return terms; } @@ -452,6 +458,11 @@ export function highlightSearchTerms(text, tokens, searchPatterns) { output = output.replace(alias, newAlias); } + + // The pattern regexes are global, so calling pattern.test() above alters their + // state. Reset lastIndex to 0 between calls to test() to ensure it returns the + // same result every time it is called with the same value of token.originalText. + pattern.lastIndex = 0; } // the new tokens are stashed in a separate map since we can't add objects to a map during iteration |