Skip to content

Commit

Permalink
Fix bug that will replace a unexpected text
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhhui committed Jul 22, 2020
1 parent f6332b0 commit 6674007
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ export function search(query) {
end = postContent.length;
}

let originKeyword = escapeHtml(postContent).substr(
indexContent,
keyword.length
);
let originKeyword = escapeHtml(postContent)
.substring(indexContent, end)
.match(regEx);
originKeyword = Array.isArray(originKeyword)
? originKeyword[0]
: keyword;

const matchContent =
'...' +
Expand Down

0 comments on commit 6674007

Please sign in to comment.