wrap non-english words in quotes

This commit is contained in:
Hongbo Wu
2023-12-07 17:59:45 +08:00
parent fe853451c5
commit bf8d081161

View File

@ -9,6 +9,10 @@ export const parseSearchQuery = (query: string): LiqeQuery => {
.replace(/(\w+):("([^"]+)"|([^")\s]+))/g, '$1:"$3$4"')
// remove any quotes that are in the array value for example: label:"test","test2" -> label:"test,test2"
.replace(/","/g, ',')
// wrap non-english words in quotes if they are not already
.replace(/([^":\s]+[\u0080-\uFFFF]+[^":\s]*)(?=\s|$|")/g, '"$1"')
console.log('searchQuery', searchQuery)
return parse(searchQuery)
}