# `IDUtils.Schemes.Handle`
[🔗](https://github.com/moefuerst/id_utils/blob/v0.1.0/lib/id_utils/schemes/handle.ex#L1)

Handle System scheme.

See https://www.rfc-editor.org/info/rfc3651/

# `build_uri`

Builds a URI for the given Handle.

## Examples

    iex> IDUtils.Schemes.Handle.build_uri("20.1000/5555")
    {:ok, %URI{scheme: "https", host: "hdl.handle.net", path: "/20.1000/5555", port: 443}}

# `hnr?`

```elixir
@spec hnr?(binary()) :: boolean()
```

Checks whether a string can be matched as a Handle with a HNR NA.

The Handle.Net Registry (HNR) allots naming authorities of the form "20.500" followed by four or
more digits, e.g., `20.500.1234`.

## Examples

    iex> IDUtils.Schemes.Handle.hnr?("20.500.1234/100")
    true

    iex> IDUtils.Schemes.Handle.hnr?("https://hdl.handle.net/20.500.1234/100")
    true

    iex> IDUtils.Schemes.Handle.hnr?("10.1000/182")
    false

# `match?`

Checks whether a string can be matched as a Handle.

> #### Limited significance {: .warning}
> The Handle System's very generic namespace (RFC 3651 basically specifies "UTF8 except `/`")
> means that many shapes will "match" as a Handle, such as any `scheme://host/...` URL,
> arbitrary strings with whitespace that happen to contain a slash, etc.
>
> For matching more narrowly according to the Handle.Net Registry (HNR) conventions
> use `hnr?/1`.

## Examples

    iex> IDUtils.Schemes.Handle.match?("20.1000/100")
    true

    iex> IDUtils.Schemes.Handle.match?("https://hdl.handle.net/20.1000/5555")
    true

    iex> IDUtils.Schemes.Handle.match?("hello world/foo")
    true

    iex> IDUtils.Schemes.Handle.match?("https://example.com")
    true

# `normalize`

Normalizes a Handle.

## Examples

    iex> IDUtils.Schemes.Handle.normalize("20.1000/5555")
    {:ok, "20.1000/5555"}

    iex> IDUtils.Schemes.Handle.normalize("https://hdl.handle.net/20.1000/5555")
    {:ok, "20.1000/5555"}

    iex> IDUtils.Schemes.Handle.normalize("hdl: 2381/12345")
    {:ok, "2381/12345"}

    iex> IDUtils.Schemes.Handle.normalize("not-a-handle")
    {:error, :invalid_identifier}

# `prefix?`

```elixir
@spec prefix?(binary()) :: boolean()
```

Checks whether a string starts with a Handle prefix.

## Examples

    iex> IDUtils.Schemes.Handle.prefix?("https://hdl.handle.net/20.1000/100")
    true

    iex> IDUtils.Schemes.Handle.prefix?("info:hdl/20.1000/100")
    true

    iex> IDUtils.Schemes.Handle.prefix?("20.1000/100")
    false

---

*Consult [api-reference.md](api-reference.md) for complete listing*
