Browse Source

ObjectID Validator: Refactor.

debug-remote-ip
lain 4 years ago
parent
commit
772bc258cd
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      lib/pleroma/web/activity_pub/object_validators/types/object_id.ex

+ 8
- 8
lib/pleroma/web/activity_pub/object_validators/types/object_id.ex View File

@@ -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


Loading…
Cancel
Save