fix some code style and add checks to ci
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
16
lib/eventos/slug.ex
Normal file
16
lib/eventos/slug.ex
Normal file
@@ -0,0 +1,16 @@
|
||||
defmodule Eventos.Slug do
|
||||
@moduledoc """
|
||||
Common functions for slug generation
|
||||
"""
|
||||
def increment_slug(slug) do
|
||||
case List.pop_at(String.split(slug, "-"), -1) do
|
||||
{nil, _} ->
|
||||
slug
|
||||
{suffix, slug_parts} ->
|
||||
case Integer.parse(suffix) do
|
||||
{id, _} -> Enum.join(slug_parts, "-") <> "-" <> Integer.to_string(id + 1)
|
||||
:error -> slug <> "-1"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user