1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Uri do
10 def cast(uri) when is_binary(uri) do
11 case URI.parse(uri) do
12 %URI{host: nil} -> :error
13 %URI{host: ""} -> :error
14 %URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, uri}
19 def cast(_), do: :error
21 def dump(data), do: {:ok, data}
23 def load(data), do: {:ok, data}