mirror of
https://git.youjo.love/youjo/youjo-be.git
synced 2024-11-20 13:59:55 +01:00
Merge branch 'bugfix/objectid_validator' into 'develop'
ObjectValidators.Types.ObjectID: Fix when URI.parse returns %URL{host: ""} See merge request pleroma/pleroma!2358
This commit is contained in:
commit
4cedecac45
1 changed files with 4 additions and 8 deletions
|
@ -6,14 +6,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
|
||||||
def cast(object) when is_binary(object) do
|
def cast(object) when is_binary(object) do
|
||||||
# Host has to be present and scheme has to be an http scheme (for now)
|
# Host has to be present and scheme has to be an http scheme (for now)
|
||||||
case URI.parse(object) do
|
case URI.parse(object) do
|
||||||
%URI{host: nil} ->
|
%URI{host: nil} -> :error
|
||||||
:error
|
%URI{host: ""} -> :error
|
||||||
|
%URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, object}
|
||||||
%URI{scheme: scheme} when scheme in ["https", "http"] ->
|
_ -> :error
|
||||||
{:ok, object}
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
:error
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue