mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-29 14:56:26 +08:00
Before Elixir master, empty path is represented as `nil`:
~% asdf shell elixir 1.12.3-otp-24 ; elixir -e 'IO.inspect URI.parse("http://localhost")'
%URI{
authority: "localhost",
fragment: nil,
host: "localhost",
path: nil,
port: 80,
query: nil,
scheme: "http",
userinfo: nil
}
On Elixir master, it is an empty string:
~% asdf shell elixir git ; elixir -e 'IO.inspect URI.parse("http://localhost")'
%URI{
authority: "localhost",
fragment: nil,
host: "localhost",
path: "",
port: 80,
query: nil,
scheme: "http",
userinfo: nil
}
The new default, the empty string, caused a bug on this line:
Map.update!(:path, &((&1 || "/") <> path))
because we never prepended the leading `/` and thus we ended up with
path `"health"`, not `"/health"`, which now on Elixir master crashes:
iex> URI.parse("http://localhost") |> Map.replace!(:path, "health") |> to_string()
** (ArgumentError) :path in URI must be empty or an absolute path if URL has a :host, got: %URI{authority: "localhost", fragment: nil, host: "localhost", path: "health", port: 80, query: nil, scheme: "http", userinfo: nil}
(elixir 1.13.0-dev) lib/uri.ex:863: String.Chars.URI.to_string/1
|
||
|---|---|---|
| .. | ||
| server.ex | ||
| task.ex | ||