zcap-spec-examples - v0.2.0
    Preparing search index...

    Function discoverBaseUrl

    • Find a URL that the document declares about itself, so that piped input (curl ... | zcap-spec-examples) can still produce absolute example URLs.

      zcap-spec is a ReSpec document, and ReSpec runs in the browser -- so the HTML you get over the wire is the source, which still carries its respecConfig. That config's edDraftURI is where the spec is published, which is exactly the base we want. Checked in order:

      1. <base href> -- the standard HTML mechanism, so it wins.
      2. respecConfig.edDraftURI
      3. <link rel="canonical" href>
      4. <meta property="og:url" content>
      5. respecConfig.latestVersion

      You rarely need to call this yourself — extractExamples already does. It is exported for when you want to know the spec's own URL.

      Parameters

      • html: string

        The HTML document to inspect.

      Returns string | undefined

      An absolute URL, or undefined if the document declares none.

      discoverBaseUrl(html); // "https://w3c-ccg.github.io/zcap-spec/"