Skip to content
Prev Previous commit
Next Next commit
Change searching by tag
  • Loading branch information
asmsuechan committed Oct 13, 2017
commit caa5deac4eb4989ef38646bf10c16552626bc4e4
10 changes: 5 additions & 5 deletions browser/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down