Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
changed regex operator to %=
zadam6906c824085a
diff --git a/src/services/search/expressions/note_content_fulltext.js b/src/services/search/expressions/note_content_fulltext.jsindex f7758ef31e..548578c2bc 100644--- a/src/services/search/expressions/note_content_fulltext.js+++ b/src/services/search/expressions/note_content_fulltext.js@@ -8,7 +8,7 @@ const protectedSessionService = require('../../protected_session');const striptags = require('striptags');const utils = require("../../utils");-const ALLOWED_OPERATORS = ['*=*', '=', '*=', '=*', '~'];+const ALLOWED_OPERATORS = ['*=*', '=', '*=', '=*', '%='];const cachedRegexes = {};@@ -25,7 +25,7 @@ class NoteContentFulltextExp extends Expression {super();if (!ALLOWED_OPERATORS.includes(operator)) {- throw new Error(`Note content can be searched only with operators: ` + ALLOWED_OPERATORS.join(", "));+ throw new Error(`Note content can be searched only with operators: ` + ALLOWED_OPERATORS.join(", ") + `, operator ${operator} given.`);}this.operator = operator;@@ -62,13 +62,14 @@ class NoteContentFulltextExp extends Expression {content = this.preprocessContent(content, type, mime);- if (this.tokens.length === 1 && this.operator !== '*=*') {+ if (this.tokens.length === 1) {const [token] = this.tokens;if ((this.operator === '=' && token === content)|| (this.operator === '*=' && content.endsWith(token))|| (this.operator === '=*' && content.startsWith(token))- || (this.operator === '~' && getRegex(token).test(content))) {+ || (this.operator === '*=*' && content.includes(token))+ || (this.operator === '%=' && getRegex(token).test(content))) {resultNoteSet.add(becca.notes[noteId]);}diff --git a/src/services/search/services/build_comparator.js b/src/services/search/services/build_comparator.jsindex 0776b834fc..6d3ba463a4 100644--- a/src/services/search/services/build_comparator.js+++ b/src/services/search/services/build_comparator.js@@ -18,7 +18,7 @@ const stringComparators = {"*=": comparedValue => (val => val && val.endsWith(comparedValue)),"=*": comparedValue => (val => val && val.startsWith(comparedValue)),"*=*": comparedValue => (val => val && val.includes(comparedValue)),- "~": comparedValue => (val => val && !!getRegex(comparedValue).test(val)),+ "%=": comparedValue => (val => val && !!getRegex(comparedValue).test(val)),};const numericComparators = {diff --git a/src/services/search/services/lex.js b/src/services/search/services/lex.jsindex 5234900f72..c6bdc2dfdc 100644--- a/src/services/search/services/lex.js+++ b/src/services/search/services/lex.js@@ -9,7 +9,7 @@ function lex(str) {let currentWord = '';function isSymbolAnOperator(chr) {- return ['=', '*', '>', '<', '!', "-", "+"].includes(chr);+ return ['=', '*', '>', '<', '!', "-", "+", '%'].includes(chr);}function isPreviousSymbolAnOperator() {diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.jsindex 32ce9eeec5..8ab99fe31d 100644--- a/src/services/search/services/parse.js+++ b/src/services/search/services/parse.js@@ -40,7 +40,7 @@ function getFulltext(tokens, searchContext) {}function isOperator(str) {- return str.match(/^[!=<>*~]+$/);+ return str.match(/^[!=<>*%]+$/);}function getExpression(tokens, searchContext, level = 0) {diff --git a/trilium.iml b/trilium.imlindex 6905b014ef..cffe441d0b 100644--- a/trilium.iml+++ b/trilium.iml@@ -13,9 +13,10 @@<excludeFolder url="file://$MODULE_DIR$/libraries" /><excludeFolder url="file://$MODULE_DIR$/docs" /><excludeFolder url="file://$MODULE_DIR$/bin/better-sqlite3" />+ <excludeFolder url="file://$MODULE_DIR$/data" /></content><orderEntry type="inheritedJdk" /><orderEntry type="sourceFolder" forTests="false" /><orderEntry type="library" name="@types/jquery" level="application" /></component>-</module>+</module>\ No newline at end of file