Browse Source

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

contrib/munin-healthcheck
Haelwenn (lanodan) Monnier 4 years ago
parent
commit
c401b00c78
No known key found for this signature in database GPG Key ID: D5B7A8E43C997DEE
1 changed files with 4 additions and 8 deletions
  1. +4
    -8
      lib/pleroma/web/activity_pub/object_validators/types/object_id.ex

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

@@ -6,14 +6,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
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…
Cancel
Save