rich media: parser: add some basic sanity checks on the returned data with pattern matching

This commit is contained in:
William Pitcock 2019-01-28 20:31:43 +00:00
parent 83b7062634
commit 0f11254a06

View file

@ -46,11 +46,11 @@ defp maybe_parse(html) do
end)
end
defp get_parsed_data(data) when data == %{} do
{:error, "No metadata found"}
defp get_parsed_data(%{title: title} = data) when is_binary(title) and byte_size(title) > 0 do
{:ok, data}
end
defp get_parsed_data(data) do
{:ok, data}
{:error, "Found metadata was invalid or incomplete: #{inspect(data)}"}
end
end