1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-26 03:06:49 +02:00

escape es reserved chars (#922)

* escape es reserved chars

* fix regex
This commit is contained in:
mihaisc 2021-10-14 05:48:40 -07:00 committed by GitHub
parent b881fdd88f
commit 9a47d065b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,10 @@ function getSortType(sortParam: string): string {
return sortTerm
}
export function escapeESReservedChars(text: string): string {
return text.replace(/([!*+\-=<>&|()\\[\]{}^~?:\\/"])/g, '\\$1')
}
export function getSearchQuery(
chainIds: number[],
text?: string,
@ -61,6 +65,7 @@ export function getSearchQuery(
accessType?: string
): any {
const emptySearchTerm = text === undefined || text === ''
text = escapeESReservedChars(text)
let searchTerm = owner
? `(publicKey.owner:${owner})`
: tags