add explicit list of underscore-safe namespaces (furbooru/philomena#28)

This commit is contained in:
byte[] 2020-09-14 20:25:40 -04:00
parent 7736cb041f
commit aefc79eb8e

View file

@ -43,6 +43,14 @@ defmodule Philomena.Tags.Tag do
"video" => "content-fanmade" "video" => "content-fanmade"
} }
@underscore_safe_namespaces [
"artist:",
"colorist:",
"editor:",
"oc:",
"photographer:"
]
@derive {Phoenix.Param, key: :slug} @derive {Phoenix.Param, key: :slug}
schema "tags" do schema "tags" do
@ -211,11 +219,12 @@ defmodule Philomena.Tags.Tag do
defp join_namespace_parts([_namespace, _name], original_name), defp join_namespace_parts([_namespace, _name], original_name),
do: original_name do: original_name
defp ununderscore(<<"artist:", _rest::binary>> = name), defp ununderscore(name) do
do: name case String.starts_with?(name, @underscore_safe_namespaces) do
true -> name
defp ununderscore(name), false -> String.replace(name, "_", " ")
do: String.replace(name, "_", " ") end
end
defp put_slug(changeset) do defp put_slug(changeset) do
slug = slug =