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:/`.
This commit is contained in:
Wojtek Mach 2022-03-02 11:29:58 +01:00
parent 1dc7c43b70
commit 864624ad2c

View file

@ -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