mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-29 19:20:46 +08:00
Also convert :: to localhost
This commit is contained in:
parent
54d1ff48f1
commit
2716f79db0
1 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue