Commit 4cedecac authored by Haelwenn's avatar Haelwenn

Merge branch 'bugfix/objectid_validator' into 'develop'

ObjectValidators.Types.ObjectID: Fix when URI.parse returns %URL{host: ""}

See merge request !2358
parents 90cbf552 c401b00c
Pipeline #24291 passed with stages
in 49 minutes and 2 seconds
......@@ -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
......
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