Skip to content

Commit 3d9f986

Browse files
committed
Move all regexes out of module attributes
Regexes aren't allowed in module attributes as of OTP 28. This moves them inline rather than hoisted at the top of the module.
1 parent 6b8d45e commit 3d9f986

3 files changed

Lines changed: 3 additions & 10 deletions

File tree

lib/oban/web/queries/job_query.ex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ defmodule Oban.Web.JobQuery do
4545

4646
@states Map.new(Oban.Job.states(), &{to_string(&1), &1})
4747

48-
# Split terms using a positive lookahead that skips splitting within double quotes
49-
@split_pattern ~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/
50-
5148
defguardp is_mysql(conf) when conf.engine == Oban.Engines.Dolphin
5249

5350
defguardp is_sqlite(conf) when conf.engine == Oban.Engines.Lite
@@ -191,7 +188,7 @@ defmodule Oban.Web.JobQuery do
191188

192189
def suggest(terms, conf, opts \\ []) do
193190
terms
194-
|> String.split(@split_pattern)
191+
|> String.split(~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/)
195192
|> List.last()
196193
|> to_string()
197194
|> case do

lib/oban/web/queries/queue_query.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ defmodule Oban.Web.QueueQuery do
2424

2525
# Searching
2626

27-
@split_pattern ~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/
28-
2927
def filterable, do: ~w(modes nodes stats)a
3028

3129
def parse(terms) when is_binary(terms) do
@@ -34,7 +32,7 @@ defmodule Oban.Web.QueueQuery do
3432

3533
def suggest(terms, conf, _opts \\ []) do
3634
terms
37-
|> String.split(@split_pattern)
35+
|> String.split(~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/)
3836
|> List.last()
3937
|> to_string()
4038
|> case do

lib/oban/web/search.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ defmodule Oban.Web.Search do
33

44
# Helpers for the search toolbar
55

6-
# Split terms using a positive lookahead that skips splitting within double quotes
7-
@split_pattern ~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/
86
@ignored_chars ~w(; / \ ` ' = * ! ? # $ & + ^ | ~ < > ( \) { } [ ])
97

108
# Suggestion tuning
@@ -16,7 +14,7 @@ defmodule Oban.Web.Search do
1614
"""
1715
def parse(terms, parser) when is_binary(terms) and is_function(parser, 1) do
1816
terms
19-
|> String.split(@split_pattern, trim: true)
17+
|> String.split(~r/\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)/, trim: true)
2018
|> Map.new(fn term ->
2119
term
2220
|> String.replace(@ignored_chars, "")

0 commit comments

Comments
 (0)