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] 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];