summaryrefslogtreecommitdiff
path: root/src/hooks/ignoreCaseRegex.ts
blob: a9ddb31f27d805dc2e812fd5076aa6c18553a455 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { HookContext } from '@feathersjs/feathers';
import _ from 'lodash';

const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
  context.params.query = _.mapValues(context.params.query, data => {
    return _.has(data, '$regex') ? _.set(data, '$options', 'i') : data;
  });
  return context;
};

export default ignoreCaseRegex;