aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-04-06 13:53:24 +0200
committerlain <lain@soykaf.club>2020-04-06 13:53:24 +0200
commit772bc258cde11b3203ad9420f69321ccd56db91a (patch)
tree22ab9540f57988b5f299a76d5612341468a12c1d
parente67cde0ed6b55450b5f309f9ed86f7f8e2a1e73f (diff)
downloadpleroma-772bc258cde11b3203ad9420f69321ccd56db91a.tar.gz
ObjectID Validator: Refactor.
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/types/object_id.ex16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex b/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
index 8e70effe4..ee10be0b0 100644
--- a/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
@@ -4,14 +4,14 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
def type, do: :string
def cast(object) when is_binary(object) do
- with %URI{
- scheme: scheme,
- host: host
- }
- when scheme in ["https", "http"] and not is_nil(host) <-
- URI.parse(object) do
- {:ok, object}
- else
+ # Host has to be present and scheme has to be an http scheme (for now)
+ case URI.parse(object) do
+ %URI{host: nil} ->
+ :error
+
+ %URI{scheme: scheme} when scheme in ["https", "http"] ->
+ {:ok, object}
+
_ ->
:error
end