Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Aug 26, 2020
1 parent 2a100fe commit 60977b8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 60977b8

Please sign in to comment.