Skip to content

Commit 7b438c8

Browse files
committed
add separator param in slugify
1 parent c770076 commit 7b438c8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/algora/shared/util.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,16 @@ defmodule Algora.Util do
293293
|> Calendar.strftime("%Y-%m-%d %H:%M:%S")
294294
end
295295

296-
def slugify(text) when is_binary(text) do
296+
def slugify(text, replace \\ "-")
297+
298+
def slugify(text, replace) when is_binary(text) do
297299
text
298300
|> String.downcase()
299301
|> String.trim()
300302
|> String.normalize(:nfd)
301303
|> String.replace(~r/[^a-z0-9\s-]/u, " ")
302-
|> String.replace(~r/[\s-]+/, "-", global: true)
304+
|> String.replace(~r/[\s-]+/, replace, global: true)
303305
end
304306

305-
def slugify(_), do: ""
307+
def slugify(_, _), do: ""
306308
end

0 commit comments

Comments
 (0)