2.4 URI

struct SerdURI

A parsed URI.

This struct directly refers to chunks in other strings, it does not own any memory itself. Thus, URIs can be parsed and/or resolved against a base URI in-place without allocating memory.

SerdChunk scheme

Scheme.

SerdChunk authority

Authority.

SerdChunk path_base

Path prefix if relative.

SerdChunk path

Path suffix.

SerdChunk query

Query.

SerdChunk fragment

Fragment.

uint8_t *serd_file_uri_parse(const uint8_t *uri, uint8_t **hostname)

Get the unescaped path and hostname from a file URI.

The returned path and *hostname must be freed with serd_free().

Parameters:
  • uri – A file URI.

  • hostname – If non-NULL, set to the hostname, if present.

Returns:

The path component of the URI.

bool serd_uri_string_has_scheme(const uint8_t *utf8)

Return true iff utf8 starts with a valid URI scheme.

SerdStatus serd_uri_parse(const uint8_t *utf8, SerdURI *out)

Parse utf8, writing result to out

void serd_uri_resolve(const SerdURI *r, const SerdURI *base, SerdURI *t)

Set target t to reference r resolved against base.

See also: RFC3986 5.2.2

size_t serd_uri_serialise(const SerdURI *uri, SerdSink sink, void *stream)

Serialise uri with a series of calls to sink

size_t serd_uri_serialise_relative(const SerdURI *uri, const SerdURI *base, const SerdURI *root, SerdSink sink, void *stream)

Serialise uri relative to base with a series of calls to sink

The uri is written as a relative URI iff if it a child of base and root. The optional root parameter must be a prefix of base and can be used keep up-references (“../”) within a certain namespace.