Skip to content

Commit 6674007

Browse files
committed
Fix bug that will replace a unexpected text
1 parent f6332b0 commit 6674007

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/plugins/search/search.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,12 @@ export function search(query) {
166166
end = postContent.length;
167167
}
168168

169-
let originKeyword = escapeHtml(postContent).substr(
170-
indexContent,
171-
keyword.length
172-
);
169+
let originKeyword = escapeHtml(postContent)
170+
.substring(indexContent, end)
171+
.match(regEx);
172+
originKeyword = Array.isArray(originKeyword)
173+
? originKeyword[0]
174+
: keyword;
173175

174176
const matchContent =
175177
'...' +

0 commit comments

Comments
 (0)