Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix($plugin-search): support non-latin characters (fix #2242) #2266

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}