Skip to content

Commit 8b611b5

Browse files
committed
feat(longtail-keywords): add support for detecting multi word substring
1 parent e17d37e commit 8b611b5

File tree

1 file changed

+2
-3
lines changed
  • admin/src/components/CMEditView/utils

1 file changed

+2
-3
lines changed

admin/src/components/CMEditView/utils/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ const buildKeywordDensityObject = (keywords, words) => {
118118
keywords.map((keyword) => {
119119
if (!_.isEmpty(keyword)) {
120120
const trimmedKeyword = keyword.trim();
121-
const count = words.filter((word) =>
122-
word.includes(trimmedKeyword)
123-
).length;
121+
const exp = new RegExp(trimmedKeyword, 'g');
122+
const count = (words.join(' ').match(exp) || []).length;
124123
if (keywordsDensity[trimmedKeyword] === undefined) {
125124
keywordsDensity[trimmedKeyword] = { count };
126125
} else {

0 commit comments

Comments
 (0)