From caa5deac4eb4989ef38646bf10c16552626bc4e4 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Fri, 13 Oct 2017 10:37:43 +0900 Subject: [PATCH] Change searching by tag --- browser/lib/search.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/browser/lib/search.js b/browser/lib/search.js index 1914bb81..65ec33a9 100644 --- a/browser/lib/search.js +++ b/browser/lib/search.js @@ -2,15 +2,15 @@ import _ from 'lodash' export default function searchFromNotes (notes, search) { if (search.trim().length === 0) return [] - let searchBlocks = search.split(' ') + const searchBlocks = search.split(' ').filter(block => { return block !== '' }) + let foundNotes = [] searchBlocks.forEach((block) => { + foundNotes = findByWord(notes, block) if (block.match(/^#.+/)) { - notes = findByTag(notes, block) - } else { - notes = findByWord(notes, block) + foundNotes = foundNotes.concat(findByTag(notes, block)) } }) - return notes + return foundNotes } function findByTag (notes, block) {