mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
15 lines
No EOL
405 B
Elixir
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 |