more carefully clean search input

This commit is contained in:
David 2018-12-29 10:49:40 -05:00
parent 4551afc6c2
commit 914ad2c204

View File

@ -46,7 +46,7 @@
} }
function search(data, searchString) { function search(data, searchString) {
searchBy = searchString.toLowerCase(); searchBy = searchString.toLowerCase().replace('"', '').replace(':', '').replace("'", '').replace(" ", '');
relevantFields = ['title', 'author', 'genre', 'publisher', 'series', 'year']; relevantFields = ['title', 'author', 'genre', 'publisher', 'series', 'year'];
if (!searchString) { if (!searchString) {
@ -56,7 +56,7 @@
renderTable(_.filter(data, function(book) { renderTable(_.filter(data, function(book) {
return _.find(_.pick(book, relevantFields), function(field) { return _.find(_.pick(book, relevantFields), function(field) {
return field.toLowerCase().replace('"', '').replace(':', '').indexOf(searchBy) !== -1; return field.toLowerCase().replace('"', '').replace(':', '').replace("'", '').replace(" ", '').indexOf(searchBy) !== -1;
}); });
})); }));
} }