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:
<base href> -- the standard HTML mechanism, so it wins.
respecConfig.edDraftURI
<link rel="canonical" href>
<meta property="og:url" content>
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.
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'sedDraftURIis where the spec is published, which is exactly the base we want. Checked in order:<base href>-- the standard HTML mechanism, so it wins.respecConfig.edDraftURI<link rel="canonical" href><meta property="og:url" content>respecConfig.latestVersionYou rarely need to call this yourself — extractExamples already does. It is exported for when you want to know the spec's own URL.