-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (26 loc) · 933 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module.exports = {
/**
* Escapes the following characters with backslashes (for use in SOQL QUERY queries):
* ' \
*
* See SFDC API docs for more details:
* https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_reservedcharacters.htm
*
* @param {String} str - search query to escape
*
* @returns {String} escapedString
*/
escapeSOQL: (str) => str.replace(/(['\\])/g, '\\$&'),
/**
* Escapes the following characters with backslashes (for use in SOSL FIND queries):
* ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -
*
* See SFDC API docs for more details:
* https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_find.htm
*
* @param {String} str - search query to escape
*
* @returns {String} escapedString
*/
escapeSOSL: (str) => str.replace(/([?&|!{}[\]()^~*:\\"'+-])/g, '\\$&'),
};