summaryrefslogtreecommitdiff
path: root/src/hooks/ignoreCaseRegex.ts
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2021-04-26 08:31:36 +0300
committereug-vs <eug-vs@keemail.me>2021-04-26 08:31:36 +0300
commit092d6b55c05e9ec653b3e51cdecd7274c974b6fb (patch)
treebf374633cd77cf59ad4f0d87d794e3a09b2e365d /src/hooks/ignoreCaseRegex.ts
parent5cba4b888ce86350b306bd65e7929e9a4f146b01 (diff)
downloadcommercel-api-092d6b55c05e9ec653b3e51cdecd7274c974b6fb.tar.gz
fix: only add $options to $regex queries
Diffstat (limited to 'src/hooks/ignoreCaseRegex.ts')
-rw-r--r--src/hooks/ignoreCaseRegex.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/hooks/ignoreCaseRegex.ts b/src/hooks/ignoreCaseRegex.ts
index e996000..3a1ab63 100644
--- a/src/hooks/ignoreCaseRegex.ts
+++ b/src/hooks/ignoreCaseRegex.ts
@@ -2,8 +2,8 @@ import { HookContext } from '@feathersjs/feathers';
import _ from 'lodash';
const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
- context.params.query = _.mapValues(context.params.query, (data, key) => {
- return key.startsWith('$') ? data : _.set(data, '$options', 'i');
+ context.params.query = _.mapValues(context.params.query, data => {
+ return '$regex' in data ? _.set(data, '$options', 'i') : data;
});
return context;
};