logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

bare_uri.ex (522B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2023 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.BareUri do
  5. use Ecto.Type
  6. def type, do: :string
  7. def cast(uri) when is_binary(uri) do
  8. parsed = URI.parse(uri)
  9. if is_nil(parsed.scheme) do
  10. :error
  11. else
  12. {:ok, uri}
  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