Skip to content

Commit

Permalink
fix($plugin-search): support non-latin characters
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaddeusJiang committed Apr 1, 2020
1 parent 88ccbc6 commit b592883
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ TODOs.md
# Typescript build dist
packages/@vuepress/shared-utils/lib/
packages/@vuepress/shared-utils/types/

#Test Coverage
/coverage
6 changes: 2 additions & 4 deletions packages/@vuepress/plugin-search/match-query.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import get from 'lodash/get'

export default (query, page, additionalStr = null) => {
Expand Down Expand Up @@ -28,15 +27,14 @@ const matchTest = (query, domain) => {
.map((word, index) => {
if (words.length === index + 1 && !hasTrailingSpace) {
// The last word - ok with the word being "startswith"-like
return `(?=.*\\b${escapeRegExp(word)})`
return `(?=.*${escapeRegExp(word)})`
} else {
// Not the last word - expect the whole word exactly
return `(?=.*\\b${escapeRegExp(word)}\\b)`
return `(?=.*${escapeRegExp(word)}.*)`
}
})
.join('') + '.+',
'gi'
)
return searchRegex.test(domain)
}

0 comments on commit b592883

Please sign in to comment.