search error handling & sanitize input for default fulltext

This commit is contained in:
zadam
2019-04-02 22:52:42 +02:00
parent fe3a0bc756
commit ef1b32d586
3 changed files with 22 additions and 5 deletions

View File

@@ -45,18 +45,20 @@ function calculateSmartValue(v) {
module.exports = function (searchText) {
// if the string doesn't start with attribute then we consider it as just standard full text search
if (!searchText.trim().startsWith("@")) {
const sanitizedSearchText = searchText.replace(/[^\w ]+/g, "");
return [
{
relation: 'and',
name: 'text',
operator: '=',
value: searchText
value: sanitizedSearchText
},
{
relation: 'or',
name: 'noteId',
operator: '=',
value: searchText
value: sanitizedSearchText
}
]
}