MCPcopy Index your code
hub / github.com/scality/cloudserver / parseLikeExpression

Function parseLikeExpression

lib/api/apiUtils/bucket/parseLikeExpression.js:6–17  ·  view source on GitHub ↗

* parse LIKE expressions * @param {string} regex - regex pattern * @return {object} MongoDB search object

(regex)

Source from the content-addressed store, hash-verified

4 * @return {object} MongoDB search object
5 */
6function parseLikeExpression(regex) {
7 if (typeof regex !== 'string') {
8 return null;
9 }
10 const split = regex.split('/');
11 if (split.length < 3 || split[0] !== '') {
12 return { $regex: regex };
13 }
14 const pattern = split.slice(1, split.length - 1).join('/');
15 const regexOpt = split[split.length - 1];
16 return { $regex: new RegExp(pattern), $options: regexOpt };
17}
18
19module.exports = parseLikeExpression;

Callers 2

parseWhereFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected