From 3131610ad8d08f3be259b8c3135ddfe80e52a8c9 Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Sat, 10 Dec 2022 06:46:56 -0500 Subject: [PATCH] Fix error when specifying custom learn notebooks (#1570) This fixes the following error: ``` 07:18:26.178 [error] #PID<0.2236.0> running LivebookWeb.Endpoint (connection #PID<0.2226.0>, stream id 6) terminated Server: localhost:8080 (http) Request: GET / ** (exit) an exception was raised: ** (ArgumentError) expected a path starting with a single / but got "data:image/svg+xml;base64,PD94bWwgdmVyc2lv..." (phoenix 1.6.15) lib/phoenix/endpoint/supervisor.ex:311: Phoenix.Endpoint.Supervisor.raise_invalid_path/1 (phoenix 1.6.15) lib/phoenix/config.ex:65: Phoenix.Config.cache/3 (livebook 0.8.0) lib/phoenix/endpoint.ex:597: LivebookWeb.Endpoint.static_path/1 (livebook 0.8.0) lib/livebook_web/live/learn_helpers.ex:15: anonymous fn/2 in LivebookWeb.LearnHelpers.notebook_card/1 (livebook 0.8.0) /Users/fhunleth/git/livebook-dev/livebook/lib/livebook_web/live/home_live.ex:119: LivebookWeb.HomeLive.render/1 (elixir 1.14.2) lib/enum.ex:1780: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3 ``` --- lib/livebook_web/live/learn_helpers.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/livebook_web/live/learn_helpers.ex b/lib/livebook_web/live/learn_helpers.ex index 2214e9be7..8a1489af8 100644 --- a/lib/livebook_web/live/learn_helpers.ex +++ b/lib/livebook_web/live/learn_helpers.ex @@ -12,7 +12,7 @@ defmodule LivebookWeb.LearnHelpers do class: "flex flex-col border-2 border-gray-100 hover:border-gray-200 rounded-2xl" do %>
{"#{@notebook_info.title} @@ -26,4 +26,7 @@ defmodule LivebookWeb.LearnHelpers do <% end %> """ end + + defp img_src(_socket, "data:" <> _ = url), do: url + defp img_src(socket, url), do: Routes.static_path(socket, url) end