IDUtils.Schemes.ARK (id_utils v0.1.0)

Copy Markdown View Source

ARK (Archival Resource Key) scheme.

See https://datatracker.ietf.org/doc/html/draft-kunze-ark-44

Summary

Functions

Builds a URI for the given ARK.

Builds a URI for the given ARK and NMA.

Check whether a string can be matched as an ARK.

Normalizes an ARK.

Functions

build_uri(ark)

Builds a URI for the given ARK.

For compact ARKs, the N2T resolver is used. If the ARK is passed as a URL string, it is parsed as-is.

Examples

iex> IDUtils.Schemes.ARK.build_uri("ark:12148/btv1b8449691v/f29")
{:ok, %URI{scheme: "https", host: "n2t.net", path: "/ark:12148/btv1b8449691v/f29", port: 443}}

iex> IDUtils.Schemes.ARK.build_uri("https://gallica.bnf.fr/ark:/12148/btv1b8449691v/f29")
{:ok, %URI{scheme: "https", host: "gallica.bnf.fr", path: "/ark:/12148/btv1b8449691v/f29", port: 443}}

build_uri(ark, resolver)

Builds a URI for the given ARK and NMA.

Parameters

  • ark - The ARK to build a URI.t/0 for.
  • resolver - The NMA resolver URL to use for building the URI.

Examples

iex> IDUtils.Schemes.ARK.build_uri("ark:/12148/btv1b8449691v/f29", "https://gallica.bnf.fr")
{:ok, %URI{scheme: "https", host: "gallica.bnf.fr", path: "/ark:/12148/btv1b8449691v/f29", port: 443}}

match?(string)

Check whether a string can be matched as an ARK.

Examples

iex> IDUtils.Schemes.ARK.match?("ark:12345/x6np1wh8k")
true

iex> IDUtils.Schemes.ARK.match?("https://gallica.bnf.fr/ark:/12148/btv1b8449691v/f29")
true

normalize(string)

Normalizes an ARK.

Examples

iex> IDUtils.Schemes.ARK.normalize("ark:/12345/x6np1wh8k")
{:ok, "ark:12345/x6np1wh8k"}

iex> IDUtils.Schemes.ARK.normalize("ark:12345/x6np1wh8k/ms/971863.pdf")
{:ok, "ark:12345/x6np1wh8k/ms/971863.pdf"}

iex> IDUtils.Schemes.ARK.normalize("https://gallica.bnf.fr/ark:/12148/bpt6k1")
{:ok, "ark:12148/bpt6k1"}