Fix double slashes in URL for new (#1013)

* Fix double slashes in URL for `new`

* Fix formatting

* Rename to append_path/2 to set_path/2
This commit is contained in:
Kevin 2022-02-18 20:57:03 +01:00 committed by GitHub
parent fb9c4fbef8
commit 4fac98e069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,7 +139,7 @@ defmodule LivebookCLI.Server do
defp check_endpoint_availability(base_url) do defp check_endpoint_availability(base_url) do
Application.ensure_all_started(:inets) Application.ensure_all_started(:inets)
health_url = append_path(base_url, "/public/health") health_url = set_path(base_url, "/public/health")
case Livebook.Utils.HTTP.request(:get, health_url) do case Livebook.Utils.HTTP.request(:get, health_url) do
{:ok, status, _headers, body} -> {:ok, status, _headers, body} ->
@ -162,7 +162,7 @@ defmodule LivebookCLI.Server do
defp open_from_args(base_url, ["new"]) do defp open_from_args(base_url, ["new"]) do
base_url base_url
|> append_path("/explore/notebooks/new") |> set_path("/explore/notebooks/new")
|> Livebook.Utils.browser_open() |> Livebook.Utils.browser_open()
end end
@ -276,10 +276,10 @@ defmodule LivebookCLI.Server do
defp opts_to_config([_opt | opts], config), do: opts_to_config(opts, config) defp opts_to_config([_opt | opts], config), do: opts_to_config(opts, config)
defp append_path(url, path) do defp set_path(url, path) do
url url
|> URI.parse() |> URI.parse()
|> Map.update!(:path, &((&1 || "") <> path)) |> Map.put(:path, path)
|> URI.to_string() |> URI.to_string()
end end