krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.14k stars 767 forks source link

Quoting a search string containing newlines with extended search syntax doesn't work #696

Closed bschlenk closed 1 year ago

bschlenk commented 1 year ago

Describe the bug

Searching for an exact match that contains a newline doesn't find any results. ### Version 6.6.2 ### Is this a regression? No ### 🔬Minimal Reproduction
const Fuse = require('fuse.js')

const books = [
  {
    "title": "Old Man's War",
    "author": "John Scalzi"
  },
  {
    "title": "The Lock\nArtist",
    "author": "Steve"
  },
  {
    "title": "Artist for Life",
    "author": "Michelangelo"
  },
]

const options = {
  useExtendedSearch: true,
  keys: ['title']
}

const fuse = new Fuse(books, options)

const results = fuse.search(`'"Lock\nArtist"`)
console.log(results)

Additional context

It looks like one possible fix is to add /s to all the multiRegex (like this one) so that the . also includes newlines. I'm okay with sending a PR if this solution sounds okay!

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days