From b79503546e98eb392cd8b8f7228718fc1da07bfc Mon Sep 17 00:00:00 2001 From: Emiel Date: Mon, 29 Jul 2024 16:21:15 +0200 Subject: [PATCH] Fix for 500 error when opening leaderboard (in preview mode) --- core/frameworks/pixel/components/table.ex | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/frameworks/pixel/components/table.ex b/core/frameworks/pixel/components/table.ex index 3225e0ef2..a2086163a 100644 --- a/core/frameworks/pixel/components/table.ex +++ b/core/frameworks/pixel/components/table.ex @@ -67,8 +67,12 @@ defmodule Frameworks.Pixel.Table do def cell(%{layout: layout, content: content} = assigns) do layout = - if layout.type == :href and not valid_url?(content) do - %{layout | type: :string} + if layout.type == :href do + if valid_url?(content) do + layout + else + %{layout | type: :string} + end else layout end @@ -115,8 +119,10 @@ defmodule Frameworks.Pixel.Table do """ end - defp valid_url?(string) do + defp valid_url?(string) when is_binary(string) do uri = URI.parse(string) uri.scheme != nil && uri.host =~ "." end + + defp valid_url?(_), do: false end