From 2716f79db0697c605941efa1d30f73c1931db571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 16 May 2024 16:18:56 +0200 Subject: [PATCH] Also convert :: to localhost --- lib/livebook/utils.ex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/livebook/utils.ex b/lib/livebook/utils.ex index f1403b6af..604d515ab 100644 --- a/lib/livebook/utils.ex +++ b/lib/livebook/utils.ex @@ -636,14 +636,18 @@ defmodule Livebook.Utils do iex> Livebook.Utils.ip_to_host({0, 0, 0, 0}) "localhost" + iex> Livebook.Utils.ip_to_host({0, 0, 0, 0, 0, 0, 0, 1}) + "::1" + + iex> Livebook.Utils.ip_to_host({0, 0, 0, 0, 0, 0, 0, 0}) + "localhost" + """ @spec ip_to_host(:inet.ip_address()) :: String.t() def ip_to_host(ip) + def ip_to_host({0, 0, 0, 0, 0, 0, 0, 0}), do: "localhost" def ip_to_host({0, 0, 0, 0}), do: "localhost" def ip_to_host({127, 0, 0, 1}), do: "localhost" - - def ip_to_host(ip) do - ip |> :inet.ntoa() |> List.to_string() - end + def ip_to_host(ip), do: ip |> :inet.ntoa() |> List.to_string() end