From b59288310a642497d4e954189922cc7393a3e1f0 Mon Sep 17 00:00:00 2001 From: TJ Date: Wed, 1 Apr 2020 10:11:24 +0900 Subject: [PATCH] fix($plugin-search): support non-latin characters --- .gitignore | 3 +++ packages/@vuepress/plugin-search/match-query.js | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 11af7c36c2..979a7e2eba 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ TODOs.md # Typescript build dist packages/@vuepress/shared-utils/lib/ packages/@vuepress/shared-utils/types/ + +#Test Coverage +/coverage diff --git a/packages/@vuepress/plugin-search/match-query.js b/packages/@vuepress/plugin-search/match-query.js index d053384cbd..34b1ac5908 100644 --- a/packages/@vuepress/plugin-search/match-query.js +++ b/packages/@vuepress/plugin-search/match-query.js @@ -1,4 +1,3 @@ - import get from 'lodash/get' export default (query, page, additionalStr = null) => { @@ -28,10 +27,10 @@ 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('') + '.+', @@ -39,4 +38,3 @@ const matchTest = (query, domain) => { ) return searchRegex.test(domain) } -