Kantoor.Feeds.Url (Kantoor v1.0.0)

The address of a calendar feed, as a person pastes it.

Only https is accepted. webcal:// (and webcals://), the scheme calendar software uses to mean "subscribe to this", is rewritten to https://. An address with a user name or password, a port other than 443, no host or more than 2048 characters is refused. The check is on the text; where the host name leads is decided at fetch time (Kantoor.Feeds.NetGuard).

Summary

Functions

The host of a normalised address: all that is ever shown.

A person-readable reason for a normalisation error (English; the UI translates).

Normalises input to an https address, or says why not.

Types

error()

@type error() ::
  :blank
  | :too_long
  | :not_https
  | :no_host
  | :credentials
  | :port
  | :invalid_host

Functions

host(url)

@spec host(String.t()) :: String.t()

The host of a normalised address: all that is ever shown.

message(atom)

@spec message(error()) :: String.t()

A person-readable reason for a normalisation error (English; the UI translates).

normalize(input)

@spec normalize(term()) :: {:ok, String.t()} | {:error, error()}

Normalises input to an https address, or says why not.

iex> Kantoor.Feeds.Url.normalize("webcal://cal.example.com/a.ics")
{:ok, "https://cal.example.com/a.ics"}