mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	fix incorrect removal of attribute filter from string, fixes #35
This commit is contained in:
		
							parent
							
								
									23a2b58b24
								
							
						
					
					
						commit
						0a9a032daa
					
				| @ -58,10 +58,16 @@ router.put('/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||
| })); | ||||
| 
 | ||||
| router.get('/', auth.checkApiAuth, wrap(async (req, res, next) => { | ||||
|     console.log("Search: ", req.query.search); | ||||
| 
 | ||||
|     let {attrFilters, searchText} = parseFilters(req.query.search); | ||||
| 
 | ||||
|     console.log(attrFilters); | ||||
| 
 | ||||
|     const {query, params} = getSearchQuery(attrFilters, searchText); | ||||
| 
 | ||||
|     console.log(query, params); | ||||
| 
 | ||||
|     const noteIds = await sql.getColumn(query, params); | ||||
| 
 | ||||
|     res.send(noteIds); | ||||
| @ -72,8 +78,12 @@ function parseFilters(searchText) { | ||||
| 
 | ||||
|     const attrRegex = /(\b(and|or)\s+)?@(!?)([\w_-]+|"[^"]+")((=|!=|<|<=|>|>=)([\w_-]+|"[^"]+"))?/i; | ||||
| 
 | ||||
|     console.log("attrRegex", attrRegex); | ||||
| 
 | ||||
|     let match = attrRegex.exec(searchText); | ||||
| 
 | ||||
|     console.log("Match: ", match); | ||||
| 
 | ||||
|     function trimQuotes(str) { return str.startsWith('"') ? str.substr(1, str.length - 2) : str; } | ||||
| 
 | ||||
|     while (match != null) { | ||||
| @ -88,7 +98,7 @@ function parseFilters(searchText) { | ||||
|         }); | ||||
| 
 | ||||
|         // remove attributes from further fulltext search
 | ||||
|         searchText = searchText.replace(new RegExp(match[0], 'g'), ''); | ||||
|         searchText = searchText.split(match[0]).join(''); | ||||
| 
 | ||||
|         match = attrRegex.exec(searchText); | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner