Skip to content

Commit ff41bbb

Browse files
committed
Fix manifest decoding
1 parent bac99dd commit ff41bbb

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

lib/phoenix_iconify/manifest.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ defmodule PhoenixIconify.Manifest do
108108
end
109109

110110
defp decode!(json) do
111+
_icon_defaults = struct!(Iconify.Icon, name: "", body: "")
111112
%{version: @version, icons: icons} = Jason.decode!(json, keys: :atoms!)
112113

113114
unless is_list(icons) do

test/phoenix_iconify/manifest_test.exs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ defmodule PhoenixIconify.ManifestTest do
3232
end
3333
end
3434

35+
test "loads icon atoms before decoding persisted icon fields" do
36+
path =
37+
Path.join(System.tmp_dir!(), "test_manifest_strings_#{:rand.uniform(1_000_000)}.json")
38+
39+
try do
40+
File.write!(
41+
path,
42+
~s({"version":1,"icons":[{"name":"lucide:sun","body":"<path/>","width":24,"height":24}]})
43+
)
44+
45+
assert %{"lucide:sun" => icon} = Manifest.read(path)
46+
assert icon.width == 24
47+
assert icon.height == 24
48+
after
49+
File.rm(path)
50+
end
51+
end
52+
3553
test "returns empty map for missing file" do
3654
assert Manifest.read("/nonexistent/path.json") == %{}
3755
end

0 commit comments

Comments
 (0)