krisk / Fuse

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

Js Fatal error if tokenSeparator is not defined. #255

Closed iruzevic closed 4 years ago

iruzevic commented 6 years ago

Version: 3.2.1 Browser: chrome latest Os: osx

I'm using fuse.js in my project, everything is fine when I build it in production mode using webpack. But when I run it via code optimisations and minification from Wp rocket cache plugin it breaks.

The problem occurs in the console:

SyntaxError: Invalid regular expression: /+/: Nothing to repeat

I debugged and the problem and it occures here:

tokenSeparator = _ref$tokenSeparator === undefined ? / +/g : _ref$tokenSeparator,

I have managed to fix this by adding this to my options:

tokenSeparator: '|',

Generally I think that the problem lies in the spacing in this line: "/ +/g" Optimisation plugin removes all unnecesery white spaces that are not strings inside quotes and when it does, your plugin will not work. Please check this and provide a fix, this is a nasty bug that happends in edge cases. At lease write this inside the documentation.

tnx. If you need any more code samples please ask.

krisk commented 6 years ago

Good find. Taking a look.

iruzevic commented 6 years ago

great tnx. I have a new update. when I put this inside options:

tokenSeparator: '|',

it works great on modern browsers but IE11 returns fatal error

github-actions[bot] commented 4 years ago

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