@metreeca/core - v0.12.0
    Preparing search index...

    Function getIRIParent

    • Extracts the identifier of the collection enclosing a reference.

      Navigates one level up a path hierarchy: the parent of a member (a/b) is the collection holding it (a/), and the parent of a collection (a/b/) is the collection enclosing it (a/). The parent always ends with a slash, drops the query and fragment of iri, and keeps its variant:

      • Hierarchical (for example, http://example.org/a/b?q#f, app:/a/b/): an absolute identifier sharing scheme and authority (http://example.org/a/, app:/a/), down to the root path (http://example.org/a and http://example.org/a/ both yield http://example.org/)
      • Internal (for example, /a/b): a root-relative path (/a/), down to the root path (/a yields /)
      • Relative (for example, a/b, a, ../a/): a path-relative reference (a/, ./, ../); as relative references may climb indefinitely, a parent always exists, expressed through .. segments where needed (.. yields ../../)

      Dot segments are resolved per RFC 3986 § 5.2.4, so http://example.org/a/./b/../c yields http://example.org/a/ and a/../b yields ./; leading .. segments of relative references are kept, as no base is available to absorb them.

      Parameters

      • iri: string

        The reference to extract the parent from

      Returns Optional<string>

      The parent reference, or undefined if iri has none: root paths of hierarchical and internal references, opaque identifiers (for example, urn:example:a), relative references with an empty path (for example, "", ?q, #f, whose parent depends on the base they are resolved against), and invalid references (for example, strings carrying an isolated UTF-16 surrogate or opening with //)