Skip to content

Commit c9582ef

Browse files
committed
improved cache name atom sanitization logic
Signed-off-by: Matteo Cafasso <[email protected]>
1 parent 86bdea7 commit c9582ef

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/rabbit_message_deduplication_exchange.ex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,19 @@ defmodule RabbitMQ.ExchangeTypeMessageDeduplication do
179179
message |> elem(2) |> elem(3)
180180
end
181181

182-
# Returns an atom composed by the resource and exchange name
182+
# Returns a sanitized atom composed by the resource and exchange name
183183
defp cache_name({:resource, resource, :exchange, exchange}) do
184-
resource = String.replace(resource, "/", "")
184+
resource =
185+
resource
186+
|> String.replace(~r/[-\. ]/, "_")
187+
|> String.replace("/", "")
188+
|> String.downcase()
189+
exchange =
190+
exchange
191+
|> String.replace(~r/[-\. ]/, "_")
192+
|> String.replace("/", "")
193+
|> String.downcase()
194+
185195
String.to_atom("cache_#{resource}_#{exchange}")
186196
end
187197

0 commit comments

Comments
 (0)