From 78775b6ee73102cc5ac71c0ee2b392c5f4f6f4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=9C=9D=E6=99=96?= Date: Fri, 24 Jul 2020 10:22:54 +0800 Subject: [PATCH] fix: Search plugin: matched text is replaced with search text (#1298) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix search plugin will replace matching text * Fix bug that will replace a unexpected text * Fix bug that will replace a unexpected text * Optimized Co-authored-by: 沈唁 <52o@qq52o.cn> --- src/plugins/search/search.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 8c253587b..093904b0e 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -170,7 +170,10 @@ export function search(query) { '...' + escapeHtml(postContent) .substring(start, end) - .replace(regEx, `${keyword}`) + + .replace( + regEx, + word => `${word}` + ) + '...'; resultStr += matchContent;