Skip to content

Commit

Permalink
Fix for 500 error when opening leaderboard (in preview mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Jul 29, 2024
1 parent c599dcd commit b795035
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/frameworks/pixel/components/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit b795035

Please sign in to comment.