mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
add explicit list of underscore-safe namespaces (furbooru/philomena#28)
This commit is contained in:
parent
7736cb041f
commit
aefc79eb8e
1 changed files with 14 additions and 5 deletions
|
@ -43,6 +43,14 @@ defmodule Philomena.Tags.Tag do
|
|||
"video" => "content-fanmade"
|
||||
}
|
||||
|
||||
@underscore_safe_namespaces [
|
||||
"artist:",
|
||||
"colorist:",
|
||||
"editor:",
|
||||
"oc:",
|
||||
"photographer:"
|
||||
]
|
||||
|
||||
@derive {Phoenix.Param, key: :slug}
|
||||
|
||||
schema "tags" do
|
||||
|
@ -211,11 +219,12 @@ defmodule Philomena.Tags.Tag do
|
|||
defp join_namespace_parts([_namespace, _name], original_name),
|
||||
do: original_name
|
||||
|
||||
defp ununderscore(<<"artist:", _rest::binary>> = name),
|
||||
do: name
|
||||
|
||||
defp ununderscore(name),
|
||||
do: String.replace(name, "_", " ")
|
||||
defp ununderscore(name) do
|
||||
case String.starts_with?(name, @underscore_safe_namespaces) do
|
||||
true -> name
|
||||
false -> String.replace(name, "_", " ")
|
||||
end
|
||||
end
|
||||
|
||||
defp put_slug(changeset) do
|
||||
slug =
|
||||
|
|
Loading…
Reference in a new issue