contactlab / contactlab-ui-components

DEPRECATED - Basic UI components for ContactLab UX design pattern library
http://contactlab.github.io/contactlab-pattern-library
Apache License 2.0
30 stars 8 forks source link

Autocomplete search needs a valid regExp #207

Closed Arual90 closed 6 years ago

Arual90 commented 6 years ago

Autocomplete-clab search functionality doesn't work when special characters are used. Es: [, +.

This is because it uses the function String.prototype.search which accepts a regExp or a string that can be turned into a RegExp.

const phrase = '[laura] è al mare';

phrase.search('laura') // -> correctly returns the index
phrase.search('[laura') // -> Uncaught SyntaxError: Invalid regular expression

'[laura' cannot be turned into a RegExp unless the special character is escaped.

How To Fix: Escape the string using https://www.npmjs.com/package/escape-string-regexp

StefanoMagrassi commented 6 years ago

closed by #208