mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 11:19:19 +00:00
instance.reachable?: Limit to binary input
This commit is contained in:
parent
e1a2e8b17c
commit
1403798820
2 changed files with 4 additions and 4 deletions
|
@ -77,7 +77,7 @@ defmodule Pleroma.Instances.Instance do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reachable?(_), do: true
|
def reachable?(url_or_host) when is_binary(url_or_host), do: true
|
||||||
|
|
||||||
def set_reachable(url_or_host) when is_binary(url_or_host) do
|
def set_reachable(url_or_host) when is_binary(url_or_host) do
|
||||||
with host <- host(url_or_host),
|
with host <- host(url_or_host),
|
||||||
|
|
|
@ -32,9 +32,9 @@ defmodule Pleroma.InstancesTest do
|
||||||
assert Instances.reachable?(URI.parse(url).host)
|
assert Instances.reachable?(URI.parse(url).host)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns true on non-binary input" do
|
test "raises FunctionClauseError exception on non-binary input" do
|
||||||
assert Instances.reachable?(nil)
|
assert_raise FunctionClauseError, fn -> Instances.reachable?(nil) end
|
||||||
assert Instances.reachable?(1)
|
assert_raise FunctionClauseError, fn -> Instances.reachable?(1) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue