Expand description
URL path primitives shared by the link pipeline.
Two concerns live here because every consumer needs both and duplicating either produces silent, platform- or scheme-specific breakage:
path_to_url— conversion of filesystem paths into URL paths. URL paths are always/-separated, butstd::pathuses the platform separator —\on Windows. Stringifying aPathwithto_string_lossy(),to_str()ordisplay()and splicing the result into a URL therefore produces/docs\guide/on Windows. Worse, downstream logic that splits on/(index-file collapsing, extension stripping, cache-key matching) then silently stops matching.is_external_url— the single answer to “does this URL leave the site?”, used by link transformation, link tracking and link validation.
It also holds srcset_url_spans / rewrite_srcset, the one reading of
an HTML srcset value, shared by the renderer’s raw-HTML URL rewrite and
QuickLook’s attachment collector so the two cannot disagree about which
bytes of a srcset are a URL.
Functions§
- is_
external_ url - Returns
truewhenurladdresses something outside this site. - is_
mbr_ query_ route - Returns
truewhenurladdresses one of mbr’s own?path=-driven viewer routes (/.mbr/videos/?path=…, and thepdfs/audio/imagessiblings), in any spelling. - path_
to_ url - Converts a relative filesystem path into a
/-separated URL path body. - rewrite_
srcset srcsetwith each candidate URL replaced by whatrewrite_urlreturns for it;Nonekeeps that URL as authored.- serialize_
as_ url - Serde helper: serializes a relative path as a
/-separated string. - srcset_
url_ spans - The byte ranges of the candidate URLs in an HTML
srcsetvalue, in order. - url_
scheme - Returns the RFC 3986 scheme of
url(without the trailing:), if any.