Don't use RegExp for tag filter (Reactification regression)

Using a regexp meant that an invalid regexp pattern would crash the tag
selector, and even if we caught that it would produce unexpected results
for some searches (e.g., anything with a period).
This commit is contained in:
Dan Stillman 2019-03-20 07:12:48 -04:00
parent 42667e7090
commit 62ea7e970a

View file

@ -170,7 +170,8 @@ Zotero.TagSelector = class TagSelectorContainer extends React.Component {
tags = Array.from(new Set(tags.map(t => t.tag)));
}
if (this.state.searchString) {
tags = tags.filter(tag => !!tag.match(new RegExp(this.state.searchString, 'i')));
let lcStr = this.state.searchString.toLowerCase();
tags = tags.filter(tag => tag.toLowerCase().startsWith(lcStr));
}
tags = tags.map((name) => {
return {