1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Fixed regressions in test units

This commit is contained in:
Laurent Cozic
2019-01-31 09:48:48 +00:00
parent 8c9a148e71
commit 242926d381
6 changed files with 121 additions and 85 deletions

View File

@ -238,6 +238,9 @@ function escapeHtml(s) {
.replace(/'/g, "'");
}
// keywords can either be a list of strings, or a list of objects with the format:
// { value: 'actualkeyword', type: 'regex/string' }
// The function surrounds the keywords wherever they are, even within other words.
function surroundKeywords(keywords, text, prefix, suffix) {
if (!keywords.length) return text;
@ -245,7 +248,8 @@ function surroundKeywords(keywords, text, prefix, suffix) {
if (k.type === 'regex') {
return stringUtilsCommon.replaceRegexDiacritics(k.valueRegex);
} else {
return stringUtilsCommon.replaceRegexDiacritics(stringUtilsCommon.pregQuote(k.value));
const value = typeof k === 'string' ? k : k.value;
return stringUtilsCommon.replaceRegexDiacritics(stringUtilsCommon.pregQuote(value));
}
}).join('|');
regexString = '(' + regexString + ')'