Skip to content

Commit

Permalink
Merge pull request #181 from sliit-foss/feat/filter-query-regex-modif…
Browse files Browse the repository at this point in the history
…iers

Feat(filter-query): added support for regexp modifiers
  • Loading branch information
Akalanka47000 authored May 8, 2024
2 parents 8730510 + 9878cc8 commit 1e1c0bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/mongoose-filter-query/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export const mapValue = (value) => {
} else if (value.startsWith("nin(")) {
return { $nin: parseOperatorValue(value, "nin").split(",") };
} else if (value.startsWith("reg(")) {
return { $regex: new RegExp(replaceOperator(value, "reg")) };
const [regex, modifiers] = replaceOperator(value, "reg").split("...[")
return { $regex: new RegExp(regex, modifiers?.slice(0, -1)) };
} else if (value.startsWith("exists(")) {
return { $exists: parseOperatorValue(value, "exists") === "true" };
}
Expand Down

0 comments on commit 1e1c0bc

Please sign in to comment.