Skip to content

Commit 687cca8

Browse files
committed
Fix warnings on Elixir v1.19
1 parent b6d63e7 commit 687cca8

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

lib/phoenix_html/safe.ex

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,36 @@ defimpl Phoenix.HTML.Safe, for: DateTime do
4545
end
4646

4747
defimpl Phoenix.HTML.Safe, for: List do
48-
def to_iodata([h | t]) do
49-
[to_iodata(h) | to_iodata(t)]
50-
end
48+
def to_iodata(list), do: recur(list)
5149

52-
def to_iodata([]) do
53-
[]
54-
end
50+
defp recur([h | t]), do: [recur(h) | recur(t)]
51+
defp recur([]), do: []
5552

56-
def to_iodata(?<), do: "&lt;"
57-
def to_iodata(?>), do: "&gt;"
58-
def to_iodata(?&), do: "&amp;"
59-
def to_iodata(?"), do: "&quot;"
60-
def to_iodata(?'), do: "&#39;"
53+
defp recur(?<), do: "&lt;"
54+
defp recur(?>), do: "&gt;"
55+
defp recur(?&), do: "&amp;"
56+
defp recur(?"), do: "&quot;"
57+
defp recur(?'), do: "&#39;"
6158

62-
def to_iodata(h) when is_integer(h) and h <= 255 do
59+
defp recur(h) when is_integer(h) and h <= 255 do
6360
h
6461
end
6562

66-
def to_iodata(h) when is_integer(h) do
63+
defp recur(h) when is_integer(h) do
6764
raise ArgumentError,
6865
"lists in Phoenix.HTML templates only support iodata, and not chardata. Integers may only represent bytes. " <>
6966
"It's likely you meant to pass a string with double quotes instead of a char list with single quotes."
7067
end
7168

72-
def to_iodata(h) when is_binary(h) do
69+
defp recur(h) when is_binary(h) do
7370
Phoenix.HTML.Engine.html_escape(h)
7471
end
7572

76-
def to_iodata({:safe, data}) do
73+
defp recur({:safe, data}) do
7774
data
7875
end
7976

80-
def to_iodata(other) do
77+
defp recur(other) do
8178
raise ArgumentError,
8279
"lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, " <>
8380
"got invalid entry: #{inspect(other)}"

0 commit comments

Comments
 (0)