Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
600B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Uri do
  5. use Ecto.Type
  6. def type, do: :string
  7. def cast(uri) when is_binary(uri) do
  8. case URI.parse(uri) do
  9. %URI{host: nil} -> :error
  10. %URI{host: ""} -> :error
  11. %URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, uri}
  12. _ -> :error
  13. end
  14. end
  15. def cast(_), do: :error
  16. def dump(data), do: {:ok, data}
  17. def load(data), do: {:ok, data}
  18. end