Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/flagsmith_engine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
type: :string,
value: t_value
}) do
case Regex.compile(value) do
case Regex.compile(value, [:anchored]) do
{:ok, regex} ->
String.match?(t_value, regex)

Expand Down Expand Up @@ -596,7 +596,7 @@
end
rescue
Decimal.Error ->
Logger.warn(

Check warning on line 599 in lib/flagsmith_engine.ex

View workflow job for this annotation

GitHub Actions / Run benchmarks

Logger.warn/1 is deprecated. Use Logger.warning/2 instead

Check warning on line 599 in lib/flagsmith_engine.ex

View workflow job for this annotation

GitHub Actions / Build and test

Logger.warn/1 is deprecated. Use Logger.warning/2 instead

Check warning on line 599 in lib/flagsmith_engine.ex

View workflow job for this annotation

GitHub Actions / Build and test

Logger.warn/1 is deprecated. Use Logger.warning/2 instead
"invalid MODULO segment rule or trait value :: rule: #{inspect(condition_value)} :: value: #{inspect(value)}"
)

Expand Down
7 changes: 7 additions & 0 deletions test/unit/segment_conditions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ defmodule Flagsmith.Engine.SegmentConditionsTest do
{:REGEX, "foo", "[a-z]+", true},
{:REGEX, "FOO", "[a-z]+", false},
{:REGEX, "1.2.3", "\\d", true},
{:REGEX, "production", "prod", true},
{:REGEX, "nonproduction", "prod", false},
{:REGEX, "development", "prod|dev", true},
{:REGEX, "nondevelopment", "prod|dev", false},
{:REGEX, "jane@example.com", "@example\\.com$", false},
{:REGEX, "jane@example.com", "^[^@]+@example\\.com$", true},
{:REGEX, "foo", "[", false},
{:MODULO, 1, "2|0", false},
{:MODULO, 2, "2|0", true},
{:MODULO, 3, "2|0", false},
Expand Down
Loading