Skip to content

Commit 12612e0

Browse files
author
tcchhabra
committed
fix for issue #3740
1 parent 33bdb8a commit 12612e0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/routes/projects/list.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,18 @@ const SUPPORTED_FILTERS = [
6262

6363
const escapeEsKeyword = keyword => keyword.replace(/[+-=><!|(){}[&\]^"~*?:\\/]/g, '\\\\$&');
6464

65+
/**
66+
* ES need to skip special chars else it is considered as RegEx
67+
*
68+
* @param {String} query query being searched for
69+
* @return {String} result after parsing
70+
*/
71+
function escapeElasticsearchQuery(query) {
72+
return query.replace(/(\+|\-|\=|&&|\|\||\>|\<|\!|\(|\)|\{|\}|\[|\]|\^|"|~|\*|\?|\:|\\|\/)/g, '\\$&');
73+
}
74+
6575
const buildEsFullTextQuery = (keyword, matchType, singleFieldName) => {
76+
keyword = escapeElasticsearchQuery(keyword);
6677
let should = [
6778
{
6879
query_string: {

0 commit comments

Comments
 (0)