philomena/lib/philomena/slug.ex
2019-11-15 10:15:21 -05:00

15 lines
No EOL
405 B
Elixir

defmodule Philomena.Slug do
def slug(string) when is_binary(string) do
string
|> String.replace("-", "-dash-")
|> String.replace("/", "-fwslash-")
|> String.replace("\\", "-bwslash-")
|> String.replace(":", "-colon-")
|> String.replace(".", "-dot-")
|> String.replace("+", "-plus-")
|> URI.encode()
|> String.replace("%20", "+")
end
def slug(_string), do: ""
end