commit: 4cedecac45a55343aadd9b1d1381fcca906f3192
parent: 90cbf55236d93383af56364947432b04aafc525d
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date: Thu, 9 Apr 2020 02:43:03 +0000
Merge branch 'bugfix/objectid_validator' into 'develop'
ObjectValidators.Types.ObjectID: Fix when URI.parse returns %URL{host: ""}
See merge request pleroma/pleroma!2358
Diffstat:
1 file changed, 4 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
@@ -6,14 +6,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
def cast(object) when is_binary(object) do
# 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
+ %URI{host: nil} -> :error
+ %URI{host: ""} -> :error
+ %URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, object}
+ _ -> :error
end
end