From 2e09afceb77836de4c59c81fce66629416a52009 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 26 Aug 2020 08:52:15 +0800 Subject: [PATCH 1/4] fix: Cannot read property 'startsWith' of undefined --- src/plugins/search/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 6a212c016..16035f864 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -208,7 +208,7 @@ export function init(config, vm) { if (Array.isArray(config.pathNamespaces)) { namespaceSuffix = - config.pathNamespaces.find(prefix => path.startsWith(prefix)) || + config.pathNamespaces.find(prefix => path && path.startsWith(prefix)) || namespaceSuffix; } else if (config.pathNamespaces instanceof RegExp) { const matches = path.match(config.pathNamespaces); From 2a100feba59ca656a39939bda751487ddbb2c4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Wed, 26 Aug 2020 13:27:43 +0800 Subject: [PATCH 2/4] Update search.js --- src/plugins/search/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 16035f864..72c2365d8 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -211,7 +211,7 @@ export function init(config, vm) { config.pathNamespaces.find(prefix => path && path.startsWith(prefix)) || namespaceSuffix; } else if (config.pathNamespaces instanceof RegExp) { - const matches = path.match(config.pathNamespaces); + const matches = path && path.match(config.pathNamespaces); if (matches) { namespaceSuffix = matches[0]; From 60977b89d24b649c9b2342b9a6e46de141396880 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 27 Aug 2020 07:38:02 +0800 Subject: [PATCH 3/4] update --- src/plugins/search/search.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 72c2365d8..e900c8732 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -199,19 +199,18 @@ export function search(query) { export function init(config, vm) { const isAuto = config.paths === 'auto'; const paths = isAuto ? getAllPaths(vm.router) : config.paths; - let namespaceSuffix = ''; // only in auto mode - if (isAuto && config.pathNamespaces) { + if (paths.length && isAuto && config.pathNamespaces) { const path = paths[0]; if (Array.isArray(config.pathNamespaces)) { namespaceSuffix = - config.pathNamespaces.find(prefix => path && path.startsWith(prefix)) || + config.pathNamespaces.find(prefix => path.startsWith(prefix)) || namespaceSuffix; } else if (config.pathNamespaces instanceof RegExp) { - const matches = path && path.match(config.pathNamespaces); + const matches = path.match(config.pathNamespaces); if (matches) { namespaceSuffix = matches[0]; From 70cdd67db68c11f0b7faf063b5921e9c616a129b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Thu, 27 Aug 2020 07:40:26 +0800 Subject: [PATCH 4/4] Update search.js --- src/plugins/search/search.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index e900c8732..7cda33071 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -199,6 +199,7 @@ export function search(query) { export function init(config, vm) { const isAuto = config.paths === 'auto'; const paths = isAuto ? getAllPaths(vm.router) : config.paths; + let namespaceSuffix = ''; // only in auto mode