From 864624ad2c25268e600e77819c63509e108de11e Mon Sep 17 00:00:00 2001 From: Wojtek Mach Date: Wed, 2 Mar 2022 11:29:58 +0100 Subject: [PATCH] Expand path before opening it Say we have this path on Windows: `C:/Users/wojtek/foo.livemd`. Opening it: (ignore it's not escaped) http://localhost:4000/open?path=C:/Users/wojtek/foo.livemd would have failed with: ** (ArgumentError) expected an expanded absolute path, got: "C:/Users/wojtek/foo.livemd" and that's because absolute paths (in other words, Path expanded) start with `c:/`, not `C:/`. --- lib/livebook_web/live/home_live.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/livebook_web/live/home_live.ex b/lib/livebook_web/live/home_live.ex index 57926ed60..04878f730 100644 --- a/lib/livebook_web/live/home_live.ex +++ b/lib/livebook_web/live/home_live.ex @@ -189,6 +189,7 @@ defmodule LivebookWeb.HomeLive do def handle_params(%{"path" => path} = _params, _uri, socket) when socket.assigns.live_action == :public_open do + path = Path.expand(path) file = FileSystem.File.local(path) if file_running?(file, socket.assigns.sessions) do