Commit 772bc258 authored by lain's avatar lain

ObjectID Validator: Refactor.

parent e67cde0e
Pipeline #24215 passed with stages
in 3 minutes and 44 seconds
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment