krisk / Fuse

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

ReferenceError: match is not defined #162

Closed chrishiste closed 7 years ago

chrishiste commented 7 years ago

Hello, I'm trying to use the key options but it throws "ReferenceError: match is not defined". Here is the code I'm using to test. I'm using fuse 3.0.3. It is fairly basic so I suppose there is something wrong in fuse code am I right ?

 const data = [
    {
      name: 'A1',
      type: 'A2',
    },
    {
      name: 'B1',
      type: 'B2',
    },
    {
      name: 'C1',
      type: 'C2',
    },
  ];
  const options = {
    keys: ['name', 'type'],
  };

  const fuse = new Fuse(data, options);
  const result = fuse.search(textToSearch);
jgstratton commented 7 years ago

Just curious why you closed this. I think there's still a bug in bitap_regex_search.js

chrishiste commented 7 years ago

@jGeek314 Ah sorry, there is indeed still a bug in fuse.js code. Unfortunately I don't really have time to dig in the codebase. The problem only occured with really long strings (containing Regex special characters like parenthesis or brackets). I suppose there is a if statement and it's not declaring?/calling? match correctly. I closed the issue because I tried previous version of fuse.js there was a similar problem but not the same error message. From there I thought my code must be wrong and the only wrong thing could only be the input I'm sending to fuse. So I'm now modifying my input first.

jgstratton commented 7 years ago

@chrishiste The bug is that when the bitap_regex_search is used, the "match" variable isn't defined in "strict mode". The solution is just adding "let". I would fix it myself but I'm having trouble navigating/understanding GitHub.