forked from AkkomaGang/akkoma
ObjectValidators.Types.ObjectID: Fix when URI.parse returns %URL{host: ""}
This commit is contained in:
parent
90cbf55236
commit
c401b00c78
1 changed files with 4 additions and 8 deletions
|
@ -6,14 +6,10 @@ def type, do: :string
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue