From bc854ee149a120f2d98c3c64cf01b04df1ee4d9c Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 21 Nov 2021 17:15:10 +0100 Subject: [PATCH] cleanup --- src/services/search/services/search.js | 7 +++++-- src/services/utils.js | 7 +------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index 1ce41a75b..37766ca15 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -218,6 +218,10 @@ function highlightSearchResults(searchResults, highlightedTokens) { } } + function wrapText(text, start, length, prefix, suffix) { + return text.substring(0, start) + prefix + text.substr(start, length) + suffix + text.substring(start + length); + } + for (const token of highlightedTokens) { for (const result of searchResults) { // Reset token @@ -226,8 +230,7 @@ function highlightSearchResults(searchResults, highlightedTokens) { // Find all matches while ((match = tokenRegex.exec(normalizeString(result.highlightedNotePathTitle))) !== null) { - console.log(match) - result.highlightedNotePathTitle = utils.wrapText(result.highlightedNotePathTitle, match.index, token.length, "{", "}"); + result.highlightedNotePathTitle = wrapText(result.highlightedNotePathTitle, match.index, token.length, "{", "}"); // 2 characters are added, so we need to adjust the index tokenRegex.lastIndex += 2; diff --git a/src/services/utils.js b/src/services/utils.js index 1795546dc..f4f31c69e 100644 --- a/src/services/utils.js +++ b/src/services/utils.js @@ -302,10 +302,6 @@ function filterAttributeName(name) { return name.replace(/[^\p{L}\p{N}_:]/ug, ""); } -function wrapText(text, start, length, prefix, suffix) { - return text.substring(0, start) + prefix + text.substr(start, length) + suffix + text.substring(start + length); -} - module.exports = { randomSecureToken, randomString, @@ -340,6 +336,5 @@ module.exports = { deferred, removeDiacritic, normalize, - filterAttributeName, - wrapText + filterAttributeName };